简体   繁体   English

safari - jquery - ajax 500内部服务器错误

[英]safari - jquery - ajax 500 internal server error

I have created an jquery ajax call and it is working fine in Chrome, firefox and IE. 我创建了一个jquery ajax调用,它在Chrome,firefox和IE中运行良好。

Where as in Safari, it is giving 500 internal server error in the response. 在Safari中,它在响应中给出了500个内部服务器错误。 I though it could be due to an exception from Server. 我虽然可能是由于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. 其中最奇怪的是,ajax-call适用于每个备用呼叫。 Call-1 fails and then call 2 succeeds. Call-1失败,然后调用2成功。 在此输入图像描述在此输入图像描述

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 谢谢你,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. 我正在从Win7运行Safari。 The actual Mac's safari loads it perfectly fine. 实际的Mac's safari可以很好地加载它。 No errors for ajax call. ajax调用没有错误。

The server is windows 2008, running iis 7. No loadbalancing servers. 服务器是Windows 2008,运行iis 7.没有负载均衡服务器。 Each time the ajax-call is hitting the same server same method, with same input-data and expects the same output data. 每次ajax调用命中相同的服务器时,使用相同的输入数据并期望相同的输出数据。

I would say that the reason the call is failing is because of a bug in Safari when working with Windows Authentication under IIS. 我会说呼叫失败的原因是因为在IIS下使用Windows身份验证时Safari中存在错误。 Go to the Authentication settings of your website. 转到您网站的身份验证设置。 Right click on Windows Authentication, choose providers and remove Negotiate, leaving NTLM which works fine. 右键单击Windows身份验证,选择提供程序并删除Negotiate,使NTLM正常工作。 I haven't tested Kerberos. 我还没有测试过Kerberos。

This issue only appears in certain builds of safari. 此问题仅出现在Safari的某些版本中。

First: I would check to make sure that $("#headerCompanyMenu").length > 0 && coId != "" evaluates to true when you think it should be. 第一:我会检查以确保$(“#headerCompanyMenu”)。length> 0 && coId!=“”在你认为应该是的时候评估为true。

Second: I would make sure that you have a '/' at the end of globalObject.rootPath when you are using Safari. 第二:当你使用Safari时,我会确保你在globalObject.rootPath的末尾有一个'/'。

Third: I would change up your ajax post to look like this: 第三:我会改变你的ajax帖子,看起来像这样:

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: 除了CCCason的评论之外,我还会通过添加以下内容明确告诉ajax调用它的数据类型是json:

dataType: "json"

Maybe safari is guessing the wrong data type? 也许safari猜测错误的数据类型?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM