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

AjaxInternet ExplorerJqueryCross Domain

Ajax Problem Overview


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?

Ajax Solutions


Solution 1 - Ajax

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!

Solution 2 - Ajax

jQuery.support.cors = true;

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

you need to make the cross domain value to true

Solution 3 - Ajax

This problem has been bugging me for some time. As a workaround I use proxy scripts located on the same site. Such scripts simply execute server-to-server non-ajax HTTP request (think of curl and WinHttp.WinHttpRequest) and pass status and data back to the caller. It works, but obviously not very efficient because it has to perform two HTTP requests.

In my case, solution is a combination of all the things described above plus 'Access-Control-Allow-Origin' header.

$.support.cors = true; // this must precede $.ajax({}) configuration

$.ajax({
  crossDomain: true, // added in jQuery 1.5
  headers: {
    'Access-Control-Allow-Origin': '*'
  },
  ...
});

The web service that answers these calls also responds with 'Access-Control-Allow-Origin: *' header.

Solution 4 - Ajax

Try this solution:

https://stackoverflow.com/a/14463975/237091

Or, simply put this code in your HTML right after including jquery.

<!--[if lte IE 9]>
<script type='text/javascript' src='//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js'></script>
<![endif]-->

Solution 5 - Ajax

I just changed the jquery version and replaced the CDN link and it worked! Just do it if crossDomain:true and $.support.cors = true not work.

<script src="https://code.jquery.com/jquery-3.5.1.js" integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc=" crossorigin="anonymous"></script>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSangView Question on Stackoverflow
Solution 1 - AjaxMagicoView Answer on Stackoverflow
Solution 2 - Ajaxamit thakurView Answer on Stackoverflow
Solution 3 - AjaxAlex DView Answer on Stackoverflow
Solution 4 - AjaxScott StaffordView Answer on Stackoverflow
Solution 5 - AjaxSagar KumarView Answer on Stackoverflow