【问题标题】:Failed to load resource: the server responded with a status of 500 using Ajax加载资源失败:服务器使用 Ajax 响应状态为 500
【发布时间】:2016-11-08 09:40:07
【问题描述】:

我知道以前有人问过这个问题,但我无法找出我的代码的确切问题。

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);

            }

网络方法:

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;

【问题讨论】:

  • 为什么不设置断点检查LoadCallDetails是否被调用。如果不检查您的帖子网址。
  • 我已经使用断点检查过。但是没有调用 LoadcallDetails @CodeFarmer

标签: javascript c# jquery asp.net ajax


【解决方案1】:

有很多问题:

  1. “pageUrl”从何而来?
  2. 您正在等待 JSON 结果,但您的方法似乎返回了一个普通对象。您在哪里转换为 JSON?
  3. 您是否尝试通过 Web 方法在单步模式下使用调试器运行?
  4. 为什么您的 Web 方法是静态的?

【讨论】:

  • 让我猜猜 - 是错误的 pageUrl?!因为如果你的断点永远不会被命中,那么你的调用地址可能是错误的。
猜你喜欢
  • 2017-10-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-10
  • 1970-01-01
  • 2015-12-19
  • 2017-06-25
  • 1970-01-01
相关资源
最近更新 更多