2009-04-21, Tue

Internet Explorer won't parse AJAX XML responses

A few components in http://stimpack.info/ required asynchronous requests to be sent, and an XML document containing the results to be parsed and display. In this case, I was using the jQuery Javascript framework, and calling the all powerful:

      $.ajax();

While testing the component on different browsers, I noticed that the results would come through fine in Firefox, but it would just blank out in Internet Explorer. Furthermore, a peek at the HTTP requests/responses indicated that server was indeed sending through the XML data, but Internet Explorer just refused to parsed it.

This is what fixed it:

      // At least in PHP
      header('Content-Type: text/xml');

You see, Internet Explorer is very strict about what it would parse as XML, and text/plain or text/html just wasn’t good enough.

As long as the content type turns up as text/xml, it’ll go ahead and do what it’s meant to do.

Isaac Su

tags: ajax http ie internet-explorer jquery php xml

---

Comment

---
 
---