开发者

Cross server AJAX Request - Works in all browsers but IE

开发者 https://www.devze.com 2023-04-03 00:54 出处:网络
Having some problems getting my cross server request to work in IE. Is it possible at all? I\'ve read up on Cross Server Requests, and it seems it depends completely on the browser. If I run the funct

Having some problems getting my cross server request to work in IE. Is it possible at all? I've read up on Cross Server Requests, and it seems it depends completely on the browser. If I run the function below in any other browser bar IE, it returns the 'success' function, IE just returns the 'error' function.

My question is, is it possible to get this to return 'success' in IE at all?

I've stripped down my J开发者_JAVA百科S code to the following:

jQuery.support.cors = true;

$.getJSON($this.attr('action'))
.error(function() {

    console.log('ERROR');

}).success(function() {

    console.log('success');

});

Thanks, Christian


In order to do cross domain AJAX requests you need to make a JSONP request which you can do by appending 'callback=?' to your url.


log the error message like

$.getJSON($this.attr('action'))
.error(function(jxhr) {

    console.log(jxhr.status+" --- "+jxhr.responseText);

}).success(function(data) {

    console.log('success');

});

what does this console.log(jxhr.status+" --- "+jxhr.responseText); line says in IE also try specifying the contentType like

$.ajaxSetup({
  cache: false,
  crossDomain: true, 
  contentType: "application/json; charset=utf-8"
 });

hope this will help

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号