Page 1 of 1

php return to ajax?

Posted: Wed Jul 14, 2010 11:42 pm
by manRay
I was wondering what the proper way to return something from a php script to an ajax script is.

Re: php return to ajax?

Posted: Wed Jul 14, 2010 11:53 pm
by liljester
ive used print or echo

Re: php return to ajax?

Posted: Thu Jul 15, 2010 12:57 pm
by Jonah Bron
Anything that goes to the output buffer is sent to Ajax. As liljester said, anything you echo/print, or even just plain HTML/text will be visible to your Javascript.

Re: php return to ajax?

Posted: Thu Jul 15, 2010 1:22 pm
by AbraCadaver
Yes, so if you just need some text etc. sent back then echo as is. If you need more structure such as an array or object of DB records for example, then you can use json_encode().