我有以下代码,我正在使用
JSONP从站点检索
JSON.我想处理像404错误请求的错误代码.以下对我不起作用.
$.getJSON('https://xyz.com/search?jsonp-callback=?',function(data) { alert("success"); }) .success(function() { alert("success 2"); }) .error(function() { alert("error occurred "); }) .complete(function() { alert("Done"); });
成功和完整的方法正在运行,但错误方法不起作用.
尝试
fail
而不是错误(参见
Deferred doc).