View Single Post
Old 12-06-2007, 02:46 PM   #4 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

The specific issues arise when you begin to use JSON - which comes highly recommend nonetheless, because JSON is typically eval()'d, the return data from the script will be executed like normal Javascript, so I'm sure you can appreciate the problem already.

Gmail was recently exposed as being susceptible to that kind of JSON hack. Thankfully, prototype not only offers a good documentation for the handling of JSON files, but it also provides a truly awesome function for safely parsing the JSON data into an array.

I feel JSON is definitely the way to go. Although AJAX was naturally created to parse XML files, XML can be quite bloated for such a simple task. You just have to remember to also set the content-type of your JSON file to application/json. This can be done using PHP, or simply adding a new MIME type - maybe both:

php Code:
header('content-type: application/json');

I also wrote an article on using JSON with PHP which you may wish to take a read of over here.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote