页面出现这个错误:“No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.”

这个原先是源于浏览器的跨域请求安全限制,解决办法可以通过设置请求Data类型jsonp或script来解决。

如:

$.ajax({
        url: "...",
        dataType: 'JSONP',
        success: function (data) {
        }
    });

 

发表评论