获取Ajax调用跨域Web API Action方法获取json结果,但我可以访问成功部分中的数据

时间:2014-03-27 02:42:42

标签: jquery ajax json asp.net-web-api cors

我在localhost中有两个应用程序,我尝试从Web API控制器中的Action方法获取信息,我在应用程序B中安装了Cors包,我从应用程序A调用了ajax:

$.ajax({    type: 'GET',
        url: httpUrlRequest,
        async: false,
        dataType:'jsonp',
        contentType: "application/json",
        cache: false,
        crossDomain: true
    })
    .success(function (data) {
        alert("IS OK");            
    })
    .fail(function (data) {
        alert(data.statusText);
    });

在应用程序BI的控制器中设置属性[EnableCors(" "," "," *")]

我可以在firebug中看到来自请求的JSON和Response选项卡中的action方法的JSON响应。在Params选项卡中,请求中的第一个参数是:
回调 jQuery18309792367157881935_1395887078261

但我从来没有进入ajax调用的成功方法(我也使用$ .getJSON而且它没有进入回调函数)。任何帮助或建议将不胜感激。

0 个答案:

没有答案