views:

383

answers:

2
$.ajax({
    type: "GET",
    url: "something.html",
    dataType: "xml",
    success:function(data){} ,
  });

The content while accessing "something.html" is an XML but the above call is failed where if I use "something.xml" it is working fine.

Is it possible to make jQuery to forcefully evaluate the data as XML, without worrying about the file extension?

+1  A: 

According to the documentation the dataType option is used to define the expected type of data. Extension is irrelevant. The MIME header will be used when no dataType is set.

kgiannakakis
+2  A: 

Your problem has nothing to do with the file extension but with the MIME type your server is sending. jQuery expects as per dataType Setting that your server is going to send response as text/xml whereas your server might be sending MIME text/html so its throwing error as kgiannakakis pointed out.

serioys sam
is there a way to override this MIME checking in jQuery?
Saneef
@Saneef you can override the MIME by using this code:Response.ContentType = "text/xml";
Khaled Musaied