简体   繁体   English

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

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

I know this question has been asked previously, but I cannot find out what is the exact problem with my code. 我知道以前曾问过这个问题,但是我无法找出我的代码的确切问题是什么。

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 Method: 网络方法:

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;

There are many things in question: 有很多问题要解决:

  1. Where does "pageUrl" comes from? “ pageUrl”来自哪里?
  2. You're awaiting a JSON result, but your method seems to return a normal object. 您正在等待JSON结果,但是您的方法似乎返回了一个普通对象。 Where do you convert to JSON? 您在哪里转换为JSON?
  3. Did you try running with a debugger in single-step mode trhough your web method? 您是否尝试通过Web方法以单步模式运行调试器?
  4. Why is your web method static? 为什么您的网络方法是静态的?

暂无
暂无

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

相关问题 Laravel 5.2和ajax无法加载资源:服务器响应状态为500 - Laravel 5.2 and ajax Failed to load resource: the server responded with a status of 500 加载资源失败:服务器响应状态为 500 (.) - Failed to load resource: the server responded with a status of 500 (.) 加载资源失败:服务器响应状态为500(内部服务器错误 - Failed to load resource: the server responded with a status of 500 (Internal Server Error Ajax错误:无法加载资源:服务器响应状态为500(内部服务器错误) - Ajax error : Failed to load resource: the server responded with a status of 500 (Internal Server Error) 加载资源失败:服务器响应状态为500(内部服务器错误)Ajax Rails错误 - Failed to load resource: the server responded with a status of 500 (Internal Server Error) Ajax Rails error Rails ajax:无法加载资源:服务器以状态404(未找到)响应 - Rails ajax: Failed to load resource: the server responded with a status of 404 (Not Found) 加载资源失败:服务器响应状态为404(未找到)。 与在caph ajax - Failed to load resource: the server responded with a status of 404 (Not Found). with ajax in caph JS / AJAX无法加载服务器响应的资源,状态为404(未找到) - JS/AJAX failed to load resource the server responded with a status of 404 (not found) 加载资源失败:服务器使用Js,ajax,php在联系表单上以404(未找到)状态进行响应 - Failed to load resource: the server responded with a status of 404 (Not Found) on contact form using Js, ajax, php 加载资源失败:服务器响应状态为 404() - Failed to load resource: the server responded with a status of 404 ()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM