在使用jquery的ajax方法获取数据时,遇到了错误提示“No ‘Access-Control-Allow-Origin’ header is present on the requested resource.”查了一下百度,这个问题和安全机制有关,默认不允许跨域调用。
处理手段:使用jsonp格式, ajax请求参数dataType:’jsonp’。
$.ajax({
url: "http://.......",
type: 'get',
dataType: 'jsonp',//here
success: function (data) {
//...
}
});
本文介绍了一个常见的跨域问题:“No ‘Access-Control-Allow-Origin’ header is present on the requested resource”。通过使用JSONP格式的Ajax请求来解决此问题。
790

被折叠的 条评论
为什么被折叠?



