dotolee Posted January 23, 2012 Share Posted January 23, 2012 hi there. i'm following an example found here: http://www.w3schools.com/php/php_ajax_database.asp in their example, the page that gets the new data from the database returns a table. so here are my questions. why do we need to "echo" the results back? also, when i do a view source on my main page, i don't see the latest values that get gnereated by the ajax code. i see the table values that initially display when i open the main page. is this correct? again, is this because the echo? Quote Link to comment Share on other sites More sharing options...
trq Posted January 24, 2012 Share Posted January 24, 2012 why do we need to "echo" the results back? You don't As per usual w3schools have published a terrible example of PHP. when i do a view source on my main page, i don't see the latest values that get gnereated by the ajax code. Javascript adds elements directly to the DOM. You won't see it in a normal "view source". Use a more robust tool like Firebug or Chrome's dev tools. Quote Link to comment Share on other sites More sharing options...
spiderwell Posted January 24, 2012 Share Posted January 24, 2012 i like how google lets me block all results from w3schools Quote Link to comment Share on other sites More sharing options...
dotolee Posted January 24, 2012 Author Share Posted January 24, 2012 why do we need to "echo" the results back? You don't As per usual w3schools have published a terrible example of PHP. when i do a view source on my main page, i don't see the latest values that get gnereated by the ajax code. Javascript adds elements directly to the DOM. You won't see it in a normal "view source". Use a more robust tool like Firebug or Chrome's dev tools. so what is the proper way to send a response back to the calling page? or do you just write straight html as you normally would.. Quote Link to comment Share on other sites More sharing options...
trq Posted January 24, 2012 Share Posted January 24, 2012 It doesn't really matter. If your Ajax expects html, send it html any way you like. I generally prefer to send json and have the JAvaScript build the html though. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.