我的代码是这样使用REST API
$.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.
所以有人可以帮我解决这个错误..?
试试'JSONP'。 –
嗨Pushpesh,我也尝试过JSONP,但它给出了相同的错误 –
你可以给我的网址,以便我可以试试看。您上面给出的网址无效,所以我无法验证。 –