开发者

jQuery.get() works on IE, but jQuery.post() does not

开发者 https://www.devze.com 2023-01-29 02:14 出处:网络
I have a very strange problem. I\'m making a pretty standard ajax-call with jQuery, but it refuses to work with Int开发者_运维知识库ernet Explorer 7.

I have a very strange problem. I'm making a pretty standard ajax-call with jQuery, but it refuses to work with Int开发者_运维知识库ernet Explorer 7.

The code is following:

$.ajax({
  url: updateUrl,
  cache: false,
  type: 'post',
  data: params, 
  success: function(data){
    handleResponse(data);
  }
 });

The weird part is that, if I change the type to 'get' everything works correctly. I have determined that with 'post' IE does not send anything to the server at all.

I'm also setting all kind of headers to prevent caching, but they have no effect on the 'post' problem.


Just so you know, according to the docs for $.post() (which is shorthand for the AJAX call):

Pages fetched with POST are never cached

Try setting a dataType for the returned data and add an error handler that will alert any errors:

$.ajax({
  url: updateUrl,
  cache: false,
  type: 'post',
  data: params, 
  success: function(data){
    handleResponse(data);
  },
  error: function(xhr,textStatus){
    alert(textStatus);
  }
 });

Also, are you sure that the page that it's posting to is getting POST variables and not only GET variables?


I was finally able to track this problem down. Ultimately the problem was a conflict between Sarissa and jQuery. A solution can be found from here. After the proposed fix, IE worked again.

The other problem was also the IE7 in CrossOver. It seems to be faulty in overall, because even with the fix it refused to work correctly.

0

精彩评论

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