Jump to content

Need help with variable passing between PHP and AJAX


Gyan1010

Recommended Posts

I have some PHP code that builds an array of data then displays the data in a table. I am trying to write code that instantly sorts the columns in the table by clicking on the column header, without reloading the page.

 

To do this I found some code that allows me to run a PHP file by calling a javascript function. So I basically have PHP that echos a string of html that calls a javascript function which instantly runs another PHP file, and inserts any output of that new PHP file it into the html string at a named <span>

 

Anyway my problem is I need access to my array in the original php file while running the 2nd. I don't know how to pass a PHP variable into javascript then pass that variable into the new PHP file that it runs with the http.open function.

If passing an array you may need to serialize www.php.net/serialize it.

 

But using ajax to pass variables you use get and post. I will not post relevant code as that is more of a javascript side part and to access it by php is simply by $_GET and $_POST.

 

I would do some searching for ajax connection functions or framework or look for an AJAX forum.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.