“没有交通”错误瓦特/ IE jQuery的ajax调用 [英] 'No Transport' Error w/ jQuery ajax call in IE

查看:151
本文介绍了“没有交通”错误瓦特/ IE jQuery的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 code是这样的:

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+'\n'+status+'\n'+xhr.statusText);
       }
    });
}

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

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

No Transport
Error
Error

我应该怎么办?

What should I do?

在此先感谢。

推荐答案

我测试了在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 jQuery的ajax调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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