site1.com
我正在做一个从到的跨域请求site2.com
(都由我维护)
这是 site1.com 上的 jquery 代码:
$.ajax({
type: 'POST',
url: 'http://site2.com/test/carrousel.cfm',
cache: false,
async: true,
crossDomain: true,
dataType: "jsonp",
success: function (data, status) {
alert(data);}
},
error: function (xhr, textStatus, errorThrown) {
alert('error');
}
});
我可以在调试器中看到状态为 200 的请求。响应正文还包含我从服务器发送的字符串。该字符串是:"okay"
奇怪的是,错误处理程序总是被触发,我无法访问数据。我也通过服务器发送Access-Control-Allow-Headers
和Access-Control-Allow-Origin
标头(我遇到了一些要求这样做的帖子)
我还收到一个脚本错误,提示“OKAY”未定义。'OKAY' 是我从服务器收到的回复字符串。怎么会这样?我怎样才能让这个跨域请求成功?
我正在使用 JQUERY 1.10.2 和 IE 10
如您所见,我还使用 jsonp 和 jquery 文档中定义的正确参数来执行跨域请求