我不确定为什么会这样,但我有一个简单的Ajax代码:
$.ajax({ url: "/javascript/testing.js"})
.done(function(data){ console.log(data) })
.fail(function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
});
Run Code Online (Sandbox Code Playgroud)
.fail()get执行状态代码为"OK".数据也存在于responceText实际的合法数据中.为什么会这样?

nul*_*ity 13
如果要解析javascript文件,那么dataType应该是script:
$.ajax({ url: "/javascript/testing.js", dataType: "script" })
.done(function(data){ console.log(data) })
.fail(function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
});
Run Code Online (Sandbox Code Playgroud)
如果你仍然有一个,parserError那么你的testing.js文件就有问题.
如果您不想解析它并只是检索它,那么dataType应该是text:
$.ajax({ url: "/javascript/testing.js", dataType: "text" })
Run Code Online (Sandbox Code Playgroud)