阿贾克斯失败,但状态code仍然是200 QUOT;确定] [英] Ajax fails but status code is still 200 "OK"
本文介绍了阿贾克斯失败,但状态code仍然是200 QUOT;确定]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道为什么会这样,但我有一个简单的Ajax code:
I'm not sure why this is happening but i have a simple Ajax Code:
$.ajax({ url: "/javascript/testing.js"})
.done(function(data){ console.log(data) })
.fail(function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
});
.fail()
获取真实执行情况code是OK。另外,数据为present在 responceText
实际合法的数据。为什么会出现这种情况?
.fail()
get's executed the status code is "OK". Also the data is present in responceText
to the actual legit data. Why is this happening?
推荐答案
如果你想解析JavaScript文件,用的数据类型应该是剧本
:
If you want to parse the javascript file, then the dataType should be script
:
$.ajax({ url: "/javascript/testing.js", dataType: "script" })
.done(function(data){ console.log(data) })
.fail(function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
});
如果你仍然得到一个 parserError
再有就是你的 testing.js
文件有问题。
If you are still getting a parserError
then there is a problem with your testing.js
file.
如果你不想分析它,只是检索它,用的数据类型应该是文本
:
If you don't want to parse it and just retrieve it, then the dataType should be text
:
$.ajax({ url: "/javascript/testing.js", dataType: "text" })
这篇关于阿贾克斯失败,但状态code仍然是200 QUOT;确定]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文