0

I have some ajax that is causing an issue in Chrome but not IE. I trapped the traffic using Fiddler and I compared it to the IE traffic and I see that the content type is missing in the Chrome request, and the verb in the chrome request is set to "Options" rather than post. When I modify those two things and resubmit with Fiddler it works fine. Any ideas what is causing these issues?

jQuery.ajax({ 
   url: url,
   type:'POST',
   contentType:"application/json; charset=utf-8",
   cache: false,
   data: request, 
   success:function(data) { 
      alert("Success!!!"); 
   }, 
   error: function(jqxhr, textStatus, errorThrown){ 
      alert("Error : " + errorThrown + " textStatus: " + textStatus );
   } 
});
BriceTRockindale
  • 309
  • 1
  • 4
  • 15
  • 1
    Here ya go: http://stackoverflow.com/questions/1742049/jquery-ajax-problem-in-chrome – Patrick Smith Mar 06 '15 at 18:41
  • @Patrick, thanks, that helps give me a better error message. The problem is not solved. The error message states "Network Error: Failed to execute 'Send' on XmlHttpRequest". What is it talking about an XmlHttpRequest when I am dealing with Json? – BriceTRockindale Mar 06 '15 at 19:28
  • Instead of contentType, use dataType: 'json' – Vim Mar 06 '15 at 19:41

1 Answers1

0

Here is the structure of the ajax I use in my project and it works perfect in IE and Chrome,

$.ajax({
            url: 'api/Test/GetData',
            type: 'POST',
            dataType: 'json',
            data: SearchRequest,
            success: function (data, textStatus, xhr) {

            },
            error: function (xhr, textStatus, errorThrown) {
            }
      });

The difference is, I use dataType: 'json' and not contentType.

Vim
  • 559
  • 5
  • 16