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.

VJOY
  • 3,752
  • 12
  • 57
  • 90

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
  • 2,018
  • 2
  • 19
  • 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
    .....
});
Earth
  • 3,477
  • 6
  • 37
  • 78
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
VJOY
  • 3,752
  • 12
  • 57
  • 90