加载资源失败:服务器使用Ajax响应状态为500

Failed to load resource: the server responded with a status of 500 using Ajax

本文关键字:响应 Ajax 状态 资源 失败 服务器 加载      更新时间:2023-09-26

我知道这个问题以前已经问过了,但是我无法找出我的代码的确切问题是什么。

function viewcalldetails(obj) {
                alert("clicked");
                var id = $(obj).attr("id");
                $(".style-table-tab input[type='text']").val('');
                setTimeout(function () {
                    $('.preloader-circle').show();// or fade, css display however you'd like.
                }, 1000);
                $.ajax({
                    type: 'POST',
                    url: pageUrl+"/LoadCallDetails",
                    data: '{LeadID: "' + id + '"}',
                    contentType: "application/json; charset=utf-8",
                    dataType: 'json',
                    success: OnValuecall,
                    failure: function (response) {
                        alert(response.d);
                    }
                });
            }

            function OnValuecall(response) {
                $(".preloader-circle").hide();
                $("#ctl00_ContentPlaceHolder1_lbrfullname").text(response.d.FirstName);
                $("#ctl00_ContentPlaceHolder1_lbrphonenumber").text(response.d.MobileNo);
                $("#ctl00_ContentPlaceHolder1_lbraddress").text(response.d.Address1);
                $("#ctl00_ContentPlaceHolder1_lbrorganization").text(response.d.OrganizationName);
                $("#ctl00_ContentPlaceHolder1_lblremail").text(response.d.PrimaryEmail);
            }
Web方法:

public static UserAjax3 LoadCallDetails(string LeadID)
    {
        //System.Threading.Thread.Sleep(3000);
        UserAjax3 oUserAjax = new UserAjax3();
        //BD_CommonEmail[] ocall = BD_CommonEmail.GetEmailAll(Convert.ToInt32(LeadID)).ToArray();
        BD_Leads[] ocall = BD_Leads.getCallDetails(Convert.ToInt32(LeadID)).ToArray();
        if (ocall.Length == 1)
        {
            //   oUserAjax.LeadID = oLeads.LeadID.ToString();
            oUserAjax.LeadID = ocall[0].LeadID.ToString();
            oUserAjax.FirstName = ocall[0].FirstName;
            oUserAjax.MobileNo = ocall[0].MobileNo;
            oUserAjax.OrganizationName = ocall[0].OrganizationName;
            oUserAjax.Address1 = ocall[0].Address1;
            oUserAjax.PrimaryEmail = ocall[0].PrimaryEmail;
        }
        return oUserAjax;

有很多问题:

  1. "pageUrl"来自哪里?
  2. 您正在等待JSON结果,但您的方法似乎返回一个正常对象。在哪里转换为JSON?
  3. 您是否尝试通过web方法在单步模式下运行调试器?
  4. 为什么你的web方法是静态的?