Jump to content
Larry Ullman's Book Forums

How To Get Data From Ajax (Js ) To Php?

Recommended Posts

I have a script that fetches XML data through PHP (books.php). Another script, view.js with AJAX and Javascript is used to display the result from books.php. Now I want to send some data like book_id, author_id etc to next PHP script through either url or in a session. books.php simply echos out XML data in one string format, which then is manipulated in view.php.





03 header('Cache-Control: no-cache');

04 header('Content-Type: text/xml');

05 //echo '<?xml version="1.0" encoding="utf-8" standalone="yes"

06 //<item>';


08 $stitle = $_GET['searchterm'];

09 $stitle = urlencode($stitle);

10 //echo $stitle;


12 $url = "books.xml?value1=" .$stitle;


14 $xml = file_get_contents($url);


16 echo $xml;



//If I manipulate xml file here, and get data into separate variables to send them to next php script, then it messes up javascript file view.js, which uses ajax to read the xml doc.


view.js uses ajax to read that xml document and print the data in web page. This data then I need to send to next php script.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...