2
我在MVC4中创建了REST API,当我从提琴手撰写请求时它工作正常。但在我的应用程序中,我需要通过jsonp调用,因为它会跨域请求。但是,当我调用这个服务它给我的错误,如下图所示:使用JSONP和JQuery调用REST API
jQuery的JSONP呼叫..
$.ajax({
type: "POST" ,
url: "http://127.0.0.1:81/api/sites/GetDomainAvailability?apikey=asfasfdsf&callback=?",
data: { SubDomain: subDomain, ParentDomain: parentDomain, ResellerId: resellerId },
cache: false,
contentType: "application/json; charset=utf-8",
success: function (response) {
if (callback)
callback(response.d);
},
error: function (response) {
if (callback)
error(response.d);
},
});
错误:
也许这可能有所帮助:http://stackoverflow.com/questions/5241088/jquery-call-to-webservice-returns-no-transport-error – mipe34
它不适用于JSONP –