passing variable from javascript to a controller via link |
[eluser]agubski[/eluser]
Hi Everyone, I wonder if somone can share the knowledge. I need to pass a variable from Javascript to a controller via link. I was thinking along the lines of hidden inputs, but not sure if this can work. It should be possible to send the data in URL request i.e. <a > ... Thanks Alex
[eluser]jdfwarrior[/eluser]
Since URL's for CI are in the form of.. http://www.example.com/controller/method/arg1/arg2/etc/ Yes you can pass a variable. Just make your variable the next part of the URI after the controller and method(function)
[eluser]agubski[/eluser]
thanks for your post. I wonder if there is a less transparent way to send variables
[eluser]kgill[/eluser]
If you want to submit it via a link then what jdfwarrior said is the right way, if you want it less transparent don't use a link, submit the form via post.
[eluser]agubski[/eluser]
As I understand Post method will require submission button. I'd like to try to avoid new buttons as they don't align well with overall site design. I wonder if I could still use link, but send variable without exposing it in URL.
[eluser]Mushex Antaranian[/eluser]
I you're using js frameworks, it's pretty simple (and with pure js it's not so hard ![]() In your markup Code: <form id="the-form"> In js (!this is jQuery code) Code: $sumbitLink = $('#submit-the-form')
[eluser]Mushex Antaranian[/eluser]
Ooh, sorry, I get you wrong.. You can just style your submit button as link with css, if it is the problem ![]()
|
Welcome Guest, Not a member yet? Register Sign In |