IE 中带有 jQ​​uery ajax 调用的“无传输"错误 [英] 'No Transport' Error w/ jQuery ajax call in IE

查看:27
本文介绍了IE 中带有 jQ​​uery ajax 调用的“无传输"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用foursquare API 来搜索场地.当然是跨域的.

I need to use foursquare API to search venues. Of course it is cross-domain.

它在 Firefox 中没有任何问题,但在 Internet Explorer 中(我测试过 7、8、9).

It has no any problems in Firefox but in Internet Explorer (7, 8, 9 I've tested).

我的 javascript 代码如下:

My javascript code looks like:

searchVenues: function(searchQuery) {
    $.ajax({
       url: 'https://api.foursquare.com/v2/venues/search',
       data: {
            sw: bound_south_west,
            ne: bound_north_east,
            query: searchQuery.query,
            oauth_token: FSQ_OAUTH_TOKEN,
            limit: 25,
            intent: 'browse',
            v: 20120206
       },
       cache: false,
       dataType: 'json',
       success: function(data) {
           displayResults(data, searchQuery.query);
       },
       error: function(xhr, status, errorThrown) {
           console.log(errorThrown+'
'+status+'
'+xhr.statusText);
       }
    });
}

在 Firefox 中,它完美地显示了接收到的数据.在 Internet Explorer 中,它登录控制台:

In Firefox, it perfectly displays received data. In Internet Explorer, it logs on console:

No Transport
Error
Error

我该怎么办?

推荐答案

我在 Windows Mobile 7 上对此进行了测试.

I tested this on Windows Mobile 7.

经过很多时间的理解,我终于找到了:

After LOTS of time spent to understand, I finally found this:

http://bugs.jquery.com/ticket/10660

解决方案很简单,只需设置:

The Solution is simple, just set this:

$.support.cors = true;

和 Ajax 跨域请求将起作用!

and Ajax cross domain requests will work!

这篇关于IE 中带有 jQ​​uery ajax 调用的“无传输"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆