views:

159

answers:

2

Hi, I'm getting a parsererror when using this ajax request in Internet Explorer (7 and 8). I'm using jquery 1.4.1

$.ajax({
  url: 'data.xml',
  dataType: 'xml',
  contentType: 'text/xml',  // also tried application/xml
  success: doFunction

});

I read somewhere else that I should set the content type, but I don't know where. The contentType param set in the above code example doesn't do anything (I could leave it out, no change).

Can I set a Content Type as <meta> tag? I tried, but then the XML won't validate.

Any thoughts on this?

A: 

Firstly, I would suggest you upgrade 1.4.2 regardless of whether or not it solves your issues.

Secondly, I wasn't ware you could stipulate an XML document (url:'data.xml') as the receipient of your Ajax Request. Please correct me if I am wrong!

James Wiseman
Didn't know 1.4.2 was out already. thnx
Jorn
Oh, and btw, you CAN use an XML file as receipient of an ajax request. You can use a normal selector query on the result to access elements.
Jorn
A: 

Ouch.. lame. it seemed that this problem occured because I opened the file in my browser by doubleclicking it in windows explorer.

Accessing it via a webserver (localhost) solved the problem.

Firefox didn't have the problem, because it is able to just open the file as if you were opening it yourself. IE really tries to do an a-synchronus request, but it has no server, so it fails.

Jorn