Javascript jQuery ajax返回未定义而不是承诺
1.8.2 导致错误“UncaughtTypeError:无法调用未定义的方法‘done’”,但请求发送,服务器响应向我发送数据! 如果我写Javascript jQuery ajax返回未定义而不是承诺,javascript,jquery,ajax,promise,Javascript,Jquery,Ajax,Promise,1.8.2 导致错误“UncaughtTypeError:无法调用未定义的方法‘done’”,但请求发送,服务器响应向我发送数据! 如果我写 $.ajax({ url: "/someurl/", async: true, dataType: 'json' }).done(function ( data ) { if( console && console.log ) { console.log("Sample of data:
$.ajax({
url: "/someurl/",
async: true,
dataType: 'json'
}).done(function ( data ) {
if( console && console.log ) {
console.log("Sample of data: ", data);
}
});
没关系,console.log着火了 您的错误可能来自您使用响应数据的方式,因为您的代码片段是正确的 为什么不运行一个fail方法并在那里测试错误呢
$.ajax({
url: "/someurl/",
async: true,
dataType: 'json',
success: function (data) { console.log(data); }
});
或者,检查您的“网络”选项卡以获取xhr响应预览?没有延迟的最新版本是1.4。在此版本中,只有-您确定版本1.8.2吗?任何包含在1.8之后的旧版本?jQuery.fn.jQuery返回我“1.8.2”,那么我现在必须放弃…:\
$.ajax({
url: "/someurl/",
async: true,
dataType: 'json'
}).fail(function (error) {
console.log(error);
});