I have created an jquery ajax call and it is working fine in Chrome, firefox and IE.
Where as in Safari, it is giving 500 internal server error in the response. I though it could be due to an exception from Server. But when i tried debugging, i found that it is not hitting the server at all.
The wierd thing in this is, the ajax-call works for every alternate calls. Call-1 fails and then call 2 succeeds.
Am attaching the screen shot of the request and response(both success and error). Please help me to fix this problem.
Thanks in advance, Raghav
var coId = globalObject.GetCompanyIdFromUrl();
if ($("#headerCompanyMenu").length > 0 && coId != "") {
var strData = "{\"coId\":\"" + coId + "\"}";
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
cache: false,
url: globalObject.rootPath + "search/webmethod.aspx/GetCoHeaderData",
data: strData,
async: true,
success: function (d) {
var coHeaderData = JSON.parse(d);
$("#lblCoNm").html(coHeaderData.lblCoNm);
$("#lbl_prim_im").html(coHeaderData.lbl_prim_im);
$("#lbl_prim_md").html(coHeaderData.lbl_prim_md);
$("#lbl_prd_own").html(coHeaderData.lbl_prd_own);
$("#lbl_geo_own").html(coHeaderData.lbl_geo_own);
$("#lbl_org_inv").html(coHeaderData.lbl_org_inv);
$("#lbl_out_inv").html(coHeaderData.lbl_out_inv);
$("#lbl_cur_val").html(coHeaderData.lbl_cur_val);
$("#lbl_nbv").html(coHeaderData.lbl_nbv);
$("#lbl_fv").html(coHeaderData.lbl_fv);
$("#lblProc").html(coHeaderData.lblProc);
$("#lblFinGrd").html(coHeaderData.lblFinGrd);
if (coHeaderData.addNewDeal == "true")
$("#lnkAddNewDeal").show();
if (coHeaderData.coDeals.length > 0) {
BindData("coDealsTmpl", coHeaderData.coDeals);
$("#coDeals").show();
}
},
error: function (error) {
//alert("Company search error");
}
});
Am running the safari from Win7. The actual Mac's safari loads it perfectly fine. No errors for ajax call.
The server is windows 2008, running iis 7. No loadbalancing servers. Each time the ajax-call is hitting the same server same method, with same input-data and expects the same output data.
The 500 Internal Server Error is a very general HTTP status code. It means something has gone wrong on the website and webserver is unable to specify what exactly, thus failing in fulfilling the request made by the client. Reload the web page.
Most of the time, the issue is only temporarily and can be corrected by trying the page again. You can use the refresh/reload button, pressing F5 , or by trying the URL again from the address bar. Sometimes this error is caused when a service restarts, and you happen to catch it at exactly the wrong time.
I would say that the reason the call is failing is because of a bug in Safari when working with Windows Authentication under IIS. Go to the Authentication settings of your website. Right click on Windows Authentication, choose providers and remove Negotiate, leaving NTLM which works fine. I haven't tested Kerberos.
This issue only appears in certain builds of safari.
First: I would check to make sure that $("#headerCompanyMenu").length > 0 && coId != "" evaluates to true when you think it should be.
Second: I would make sure that you have a '/' at the end of globalObject.rootPath
when you are using Safari.
Third: I would change up your ajax post to look like this:
var coId = globalObject.GetCompanyIdFromUrl();
if ($("#headerCompanyMenu").length > 0 && coId != "") {
var strData = {'coId' : coId};
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
cache: false,
url: globalObject.rootPath + "search/webmethod.aspx/GetCoHeaderData/",
data: strData,
dataType: "json",
async: true,
success: function (d) {
var coHeaderData = JSON.parse(d);
$("#lblCoNm").html(coHeaderData.lblCoNm);
$("#lbl_prim_im").html(coHeaderData.lbl_prim_im);
$("#lbl_prim_md").html(coHeaderData.lbl_prim_md);
$("#lbl_prd_own").html(coHeaderData.lbl_prd_own);
$("#lbl_geo_own").html(coHeaderData.lbl_geo_own);
$("#lbl_org_inv").html(coHeaderData.lbl_org_inv);
$("#lbl_out_inv").html(coHeaderData.lbl_out_inv);
$("#lbl_cur_val").html(coHeaderData.lbl_cur_val);
$("#lbl_nbv").html(coHeaderData.lbl_nbv);
$("#lbl_fv").html(coHeaderData.lbl_fv);
$("#lblProc").html(coHeaderData.lblProc);
$("#lblFinGrd").html(coHeaderData.lblFinGrd);
if (coHeaderData.addNewDeal == "true")
$("#lnkAddNewDeal").show();
if (coHeaderData.coDeals.length > 0) {
BindData("coDealsTmpl", coHeaderData.coDeals);
$("#coDeals").show();
}
},
error: function (error) {
//alert("Company search error");
}
});
In addition to CCCason's comments, I would explicitly tell the ajax call that it's datatype is json by adding:
dataType: "json"
Maybe safari is guessing the wrong data type?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With