【发布时间】:2012-09-24 01:34:58
【问题描述】:
我的代码是这样的
$.ajax({
cache: false,
url: <Web Service URL>,
data: "{}",
type: 'GET',
crossDomain: true,
dataType: 'json',
success: function() { alert("Success"); },
error: function() { alert('Failed!'); },
});
我正在尝试使用 JQuery 从客户端访问 REST API,但它给出了类似的错误
XMLHttpRequest cannot load <Web Service URL>. Origin null is not allowed by Access-Control-Allow-Origin.
那么有人可以帮我解决这个错误吗..?
【问题讨论】:
-
嗨,Pushpesh,我也尝试了 JSONP,但它给出了同样的错误
-
你能给我一个有效的网址,以便我试一试。您上面提供的网址无效,因此我无法验证。
-
嗨,Pushpesh,它现在对我有用..
标签: javascript ajax jquery