I need to set a view filter based on user input (checking/unchecking a box). There is no guarantee that the user will switch pages or submit anything before this information is needed in the filter, so it needs to be done at the time of input. Is there a way to access and change the variable in jquery?
-
It's just a variable that controls content on the page. The content is generated dynamically by a completely different program (that doesn't belong to me and I don't have access to or the ability to change). Just like every other view variables, it's accessed using $this->filter['thingIAmTryingToChange'] on the actual php portion of the webpage. – Sep 22 '12 at 21:03
-
On clicking check box call an ajax function and set the view and return it to the frond end user .This will solve your problem ? – Jobin Sep 28 '12 at 07:27
2 Answers
If you want to change server-side variables while on the client side using jQuery, AJAX(AJAX = Asynchronous JavaScript and XML) is your surviver.
AJAX is not a new programming language, but a new way to use existing standards. AJAX is the art of exchanging data with a server, and updating parts of a web page - without reloading the whole page.
Refer the jQuery API
Read more for a Sample AJAX call.
This similar question or just might help your problem shows how to get the GET and or POST data of a page.
how to get GET and POST variables with JQuery?
Otherwise sending data to the server without a submit or page load is possible with jQuery.ajax()
So you make a call like:
jQuery.ajax('somewebpage.php?someVariable=someValue&someOtherVariable=someOtherValue');
and in the PHP file you save that data to the session or database. And on the next page load that data can be used.