【发布时间】:2011-12-31 05:19:09
【问题描述】:
我有以下代码来执行跨域请求并获取 JSONP 数据(由回调方法包装的 JSON)。我已经验证我使用包含我的 JSON 数据的回调方法正确地获得了响应。它在 IE7 中完美运行(回调 cb 被调用),但在 IE8 中却没有。
$(document).ready(function () {
var abc = $.ajax({
type: "GET",
url: "http://sd.domain.com/param1=a¶m2=b&output=json&callback=cb",
dataType: "jsonp",
jsonp: false,
cache: false,
success: function (json) {
},
error: function (e) {
}
});
abc.error(function (data, xhr, dat1) {
});
abc.complete(function (xhr, status) {
var data = xhr.responseText;
});
});
function cb(dd) {
alert(dd.people[0].nameFirst);
}
我在 xhr 中将 statusText 设为“Success”,将 StatusCode 设为 200。此外,我无法为 xhr 找到任何正确称为 responseText 的内容。那么如何在错误/完整功能中获得响应?有什么想法吗?
【问题讨论】:
标签: jquery internet-explorer-8 cross-domain jsonp