php return to ajax?
Moderator: General Moderators
php return to ajax?
I was wondering what the proper way to return something from a php script to an ajax script is.
Re: php return to ajax?
ive used print or echo
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: php return to ajax?
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.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: php return to ajax?
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().
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.