Jump to content

newbie to ajax - response is not formatted correctly.


dotolee

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.