Subscribe to
Posts
Comments
NSLog(); Header Image

AJAX

I used AJAX today. This tutorial helped.

I cheated, though. My data is fetched from a PHP script. I didn't want to create and return valid XML because parsing is such a PITA, so my PHP script just returns a big ol' HTML string. Then I use the request's responseText instead of parsing the responseXML.

Hee hee. 😉

One Response to "AJAX"

  1. Since the alternative takes longer and has no technical advantages, I wouldn't call this "cheating." (Also, why would using PHP be cheating at all? It has to be that or something else that can dynamically fetch and format data server-side, so why not?)

    If you ever do need to have a script pass something to a JavaScipt request in a structured format that can be manipulated instead of just directly presented, I'd recommend JSON instead of XML. It makes little sense that XML is being promoted as an ideal means for JavaScript to fetch data dynamically from a server. "Parsing" JSON data is nothing more than an eval(), and it's also lighter and usually more human-readable than XML.