0

I am trying to call a webservice with jQuery ajax. The code is like;

 $.ajax({
                async: false,
                type: "POST",
                crossDomain: true,
                contentType: "application/json; charset=utf-8",
                data: <Data in JSON format>,
                url: <Url>,        // in same domain
                success: OnSuccess,
                error: OnFailure
            });

However when I run it in IE10 it is working. In IE9 it gives error. I have other pages as well on which I am using jQuery ajax, there it is working fine.

I am clueless now why this is happening.

Vijay Balkawade
  • 3,654
  • 12
  • 53
  • 88

3 Answers3

0

The problem lands on the crossDomain: true property, not in the ajax call itself.

This plugin should help: https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest

viarnes
  • 1,878
  • 2
  • 16
  • 31
0

The problem is that it turns out that for some reason jQuery/IE does not correctly urlencode double quotes.

Check the The URL of the request with IE10 and IE9.

Also, change the content-type from application/json; charset=utf8 to just plain application/json

and also try using the cache: false parameter.

$.ajax({
    .....
    .....
    url: "yoururl",
    cache: false
    .....
});
Programmer
  • 803
  • 1
  • 7
  • 27
0

I was able to resolve this by adding

$.support.cors = true;

at the beginning.

This post helped me to solve this.

Community
  • 1
  • 1
Vijay Balkawade
  • 3,654
  • 12
  • 53
  • 88