强制评估AJAX数据作为XML jQuery中 [英] Evaluating ajax data forcefully as XML in jquery
问题描述
$.ajax({
type: "GET",
url: "something.html",
dataType: "xml",
success:function(data){} ,
});
的内容,同时访问something.html是一个XML,但如果我用上面的调用失败,其中something.xml这是工作的罚款。
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.
是否有可能让jQuery来强制评估数据为XML,而无需担心文件扩展名?
Is it possible to make jQuery to forcefully evaluate the data as XML, without worrying about the file extension?
推荐答案
您的问题无关的文件扩展名,但与MIME类型服务器发送。 jQuery的预计,按照dataType的设置,你的服务器将发送响应,为text / xml ,而你的服务器可能会被发送MIME 的text / html 所以它的投掷误差kgiannakakis指出
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.
这篇关于强制评估AJAX数据作为XML jQuery中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!