我遇到问题实施jQuery AJAX与jsonp响应。我尝试访问它,但我的失败回调函数被调用。我想让我的成功回调函数被调用。用jsonp响应实现jQuery AJAX
另请注意,在普通JavaScript中,我已经实现了它,并且我知道jsonp和跨域ajax基金会。它在我失败的jQuery上。
的JSONP位置 - here
的代码是:
$.ajax({
url: "http://www.demo.yogihosting.com/jquery/jsonp/data1.json",
dataType: "jsonp",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (result, status, xhr) {
alert(result);
},
error: function (xhr, status, error) {
alert("Result: " + status + " " + error + " " + xhr.status + " " + xhr.statusText)
}
});
您可以在jQuery AJAX with jsonp on CodePen查看此。
请帮忙!
你可以发布失败的回调错误消息吗? – 2017-10-08 19:27:33
@SamDev我试图从本地获取jsonp响应,并且出现此错误 - 'jQuery31006235097177340809_1507490891841未被称为200负载' – yogihosting
尝试使用dataType:“json” – 2017-10-08 19:31:59