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

I have a very strange problem. I'm making a pretty standard ajax-call with jQuery, but it refuses to work with Internet 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.

Answers


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.


Need Your Help

Which is more efficient, a for-each loop, or an iterator?

java collections foreach

Which is the most efficient way to traverse a collection?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.