General AJAX Question
Posted: Tue Mar 09, 2010 2:48 pm
Hi, first of all I hope th question doesn't sound too stupid but I am very new to php (but not to programming though).
#1. I need to modify a PHP-variable from inside a JavaScript.
#2. Let's assume it's the onchange-Event of a Combobox or the like.
#3. The JavaScript Code should do something and finally set a couple of local variables.
I thought I could do it with AJAX. And in fact I am as far as
#1-#3 is executed
When executing 3 I finally instantiate an ajax-object and open a php-Page:
And still this works fine. But what do I do with this variable there????
I would need to get it into my mainscript in order to do something.
Well as a matter of fact I am able to write to a database within
ajtest.php. So I could verify that everything works and the correct data is being processed.
But how do I get this into my actual page (index.php).
And furthermore I don't think this can be the right way to pass some data from Javascript to PHP, by storing the data in a database.
Otherwise it would be easier to redirect the whole document to
something-or-other.php?foo=2
and passing the stuff via URL-parameters.
Ok, I understand that this is not applicable to big datasets, but somehow I think I missed the knack.
Thanks for your help in advance
Any help appreciated
#1. I need to modify a PHP-variable from inside a JavaScript.
#2. Let's assume it's the onchange-Event of a Combobox or the like.
#3. The JavaScript Code should do something and finally set a couple of local variables.
I thought I could do it with AJAX. And in fact I am as far as
#1-#3 is executed
When executing 3 I finally instantiate an ajax-object and open a php-Page:
Code: Select all
ajax.open('POST', 'http://localhost:6000/ajtest.php', true);I would need to get it into my mainscript in order to do something.
Well as a matter of fact I am able to write to a database within
ajtest.php. So I could verify that everything works and the correct data is being processed.
But how do I get this into my actual page (index.php).
And furthermore I don't think this can be the right way to pass some data from Javascript to PHP, by storing the data in a database.
Otherwise it would be easier to redirect the whole document to
something-or-other.php?foo=2
and passing the stuff via URL-parameters.
Ok, I understand that this is not applicable to big datasets, but somehow I think I missed the knack.
Thanks for your help in advance
Any help appreciated