无法加载资源:服务器在控制器中响应状态为500(内部服务器错误)

时间:2019-01-31 03:55:29

标签: jquery ajax

我正在尝试使用Chrome中的Ajax发送呼叫,这是上升错误。它不能调用该方法。

Ajax

function BuildTree() {

    $.ajax({
        type: 'POST',
        url: "/Payroll/GetTreeData",
        async: false,
        data: "{'mainItem':'2'}",
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        success: function (data) {

            if (data) {
                $('#tree').treeview({
                    data: data,
                    enableLinks: true,
                    showBorder: false,
                    onNodeSelected: function (event, data) {
                        if (data.tags instanceof Array) {
                            //DoStuffWhenClickingOnNode(data.tags[0]);
                            //alert("Action done!");
                             $.ajax({
                                type: "POST",
                                url: "@Url.Action("GetPaysheet", "Payroll")",
                                data: JSON.stringify({ Sheet_ID: data.tags[0] }),
                                contentType: "application/json; charset=utf-8",
                                dataType: "json",

                                success: function (data) {

                                    location.reload();

                                }
                            });
                        }
                    }
                });
            }
        },
        error: function (error) {
            alert(error.responseText);
        }
    });

控制器

public ActionResult GetPaysheet(string Sheet_ID)
    {
        DataUtility dUtil = new DataUtility();

        DataTable payTable = dUtil.Get_DataTable("Select s.*, d.Dept_Name From PaySheet s Left Join Department d On s.Dept_ID = d.Dept_ID Where isnull(s.Parent_Sheet_ID,0)<>0 And s.Sheet_ID = " + Sheet_ID);
        objModelLists.PaySheet = payTable;
        return View(objModelLists);

    }

0 个答案:

没有答案