Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'No Transport' Error w/ jQuery ajax call in IE

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

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

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);        }     }); } 

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

No Transport Error Error 

What should I do?

like image 907
Sang Avatar asked Feb 06 '12 12:02

Sang


2 Answers

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; 

and Ajax cross domain requests will work!

like image 157
Magico Avatar answered Sep 21 '22 10:09

Magico


jQuery.support.cors = true;  $.ajax({   crossDomain: true,   url: "",   type: "POST",   dataType: "xml",   data: soapMessage, }); 

you need to make the cross domain value to true

like image 27
amit thakur Avatar answered Sep 20 '22 10:09

amit thakur