views:

2342

answers:

5

i have the following jquery code running on my page just fine in FF and IE, but chrome seems to be freaking out..

in FF and IE the call is made and the result is appended to the div. in chrome, it calls ajaxfailed on failure.

the XMLHttpRequest passed to the AjaxFailed function has a status code of "200" and the statusText is "ok". the readystate is 4 and the responseText is set to the data i wish to append to the div.. basically from what i can see its calling the failure method but it isn't failing.. i have tried with both get and post requests and it always breaks in chrome.

function getBranchDetails(contactID, branchID) {
  $.ajax({
    type: "GET",
    url: urlToRequestTo,
    data: "{}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: branchDetailsSuccess,
    error: AjaxFailed
  });
}



 function branchDetailsSuccess(result) {
      $("#divBranchControl").empty();
      $("#divBranchControl").append(" " + result);
      $("#branchDiv").tabs();
    }



 function AjaxFailed(result) {
      alert("FAILED : " + result.status + ' ' + result.statusText);
    }
+1  A: 

Try this for success :

success: function(response) { branchDetailsSuccess(response); },
Jimmeh
no go, i'm afraid.thanks for the idea though...
spaceman
+1  A: 

Try setting the data parameter to "".

For GET requests, the data parameter is appended to the URL. Not sure why Chrome would have an issue with that but it's worth a shot :)

Lobstrosity
thanks for the idea, but once again chrome gives me the finger...i have made one of two other methods since yesterday and they work fine using the layout above.. so im trying to figure out what exactly is going wrong in this case.
spaceman
+5  A: 

after a day and a half i got over it, so may i present.....

function getBranchDetails(contactID, branchID) {

  $.ajax({
    type: "GET",
    url: urlToRequestTo,
    data: "",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: branchDetailsSuccess,
    error: branchAjaxFailed
  });
}

function branchDetailsSuccess(result) {
  $("#divBranchControl").empty();
  $("#divBranchControl").append(" " + result);
  $("#branchDiv").tabs();
}

function branchAjaxFailed(result) {
  if (result.status == 200 && result.statusText == "OK") {
    //this is here only because chrome breaks on this method only for no reason whatsoever.
    //chrome sees the request as failed, but everything happens fine...
    branchDetailsSuccess(result.responseText);
  }
  else {
    alert("FAILED : " + result.status + ' ' + result.statusText);
  }
}
spaceman
i'm having the same problem as you, and this solution seems silly to me. Please update us if you find any more information regarding this.thanks for sharing this workaround anyway.
Moe Salih
I ran in to this today, setting the data part to "" did the trick. Thanks!
jonnii
I also had this issue - data: "" was the key.
RJ Owen
A: 

With google chrome bug exist.

yAnTar
Can you share info s.a. has the bug been acknowledged by Chrome authors (or even filed there). Is there a ticket for it?
akauppi
+1  A: 

I don't know if you still have this issue, but I ran into a similar error just today. I was calling an aspx page to return a string with responseText and Chrome never returned anything. Turned out I had a Response.Close in my aspx page which worked everywhere else but probably didn't send some required headers or something to Chrome and/or Safari. Hope that helps someone.

Krokador
This worked for me - thanks.
Jordan