Your php program simply 'echo's its data. That data can be HTML, XML, JSON, etc, but whatever it is the $.ajax call needs to be aware of the type of data expected to be returned (dataType), and it can then inspect the returned data in its success handler and, if necessary, act on it.
Example (very simple!): /* * AjaxHandler.php */ <?php $myName = $_SERVER['PHP_SELF']; echo "<div id='ajaxOne'>Hello World, from $myName</div>"; ?> In the success handler the data is the String... "<div id='ajaxOne'>Hello World, from AjaxHandler.php</div>" ... which can then be appended/prepended to body, or manipulated using String techniques, or ignored completely, or whatever you wish to do with it. If you want to return JSON data from AjaxHandler.php simply echo it (this is over-simplified but still...) ... echo "{ok: true, data{sessionId: '$phpSessionId', progName: 'AjaxHandler.php', from: 'Wizzud'}}"; Then tell $.ajax that it is expecting JSON data, and the success handler will receive data as on object... { ok: true , data: { sessionId: '12345ABCD6789' , progName: 'AjaxHandler.php' , from: 'Wizzud' } } >From within your success handler you can do what you like with that data, eg .... ..... dataType:'json', success:function(json){ if(json.ok){ $('#myHeader').text(json.data.from); } }, ..... HTH. Tek7 wrote: > > Hello all, > > I apologize as i'm sure I could discern this within the forums, but after > much looking i've had a little difficulty understanding. I think once I > push past this confusion i'll be able to go forward with everything else: > > > How on earth can I grab data from a php page within my jquery? To be more > specific, here is a small block of code I had, (just a snippet nestled > between script tags): > > > function test() { > $.ajax({ > url: 'AjaxHandler.php?a=' + document.forms[0].txt.value, > success: XXXXXXXXXX > }); > } > > So let's assume I want to call load ajaxhandler.php, pass in the variable > a, examine the var in ajaxhandler.php, and output some text as a result of > what was passed. On success, I want to call some function in XXXXXXXXXX > and have it alter the inner html of a div on the page. I want the inner > html to be altered based on php session data (or a message returned from > ajaxhandler.php, let's say. i don't care which). How do i get the data? > I'm a little confused how php sends data back. > > Thanks so much for shedding light, > > Mike > -- View this message in context: http://www.nabble.com/newbie-question-tf4446564s15494.html#a12688310 Sent from the JQuery mailing list archive at Nabble.com.