Jquery 使用Ajax asp.net MVC路由到操作

Jquery 使用Ajax asp.net MVC路由到操作,jquery,asp.net-mvc-4,jqgrid-asp.net,Jquery,Asp.net Mvc 4,Jqgrid Asp.net,我正试图让我的jqGrid在点击按钮时加载数据。。。到目前为止,我已经准备好可以点击我的按钮了,正如你所看到的。问题是,我不知如何才能获得正确的导航信息。。。我正在尝试AJAX调用一个使用@HTML.BeginForm设置的函数,就像这样 @using(Html.BeginForm("returnJSONEncoutnerData", "AddEncounter", new { popId = (int)TempData["POPULATIONID"]}, FormMethod.Post, ne

我正试图让我的jqGrid在点击按钮时加载数据。。。到目前为止,我已经准备好可以点击我的按钮了,正如你所看到的。问题是,我不知如何才能获得正确的导航信息。。。我正在尝试AJAX调用一个使用
@HTML.BeginForm
设置的函数,就像这样

@using(Html.BeginForm("returnJSONEncoutnerData", "AddEncounter", new { popId = (int)TempData["POPULATIONID"]}, FormMethod.Post, new { id = "SearchPatID" }))
这是我的按钮点击功能

$('#submit').click(function (event) {
        //alert("What the FONK is going on here!");
        debugger;
        var theURL = $("#SearchPatID").action;
        var type = $("#SearchPatID").methd;
        event.preventDefault();
        $.ajax({
            url: this.action,
            type: this.method,
            data: $(this).serialize(),
            dataType: "json",
            success: function (result) {
                bindCustomers();
            }
        });
        return false;
    });
我的函数bindCustomer应该用上面的方法收集并jsonified的JSON数据填充jqGrid! 我想我会把它放在那里来满足你的好奇心

 var bindCustomers = function () {
    alert('');
    $("#list").jqGrid({
        url: $("#DisplayUniqueEncounters").attr("action"), //'/Home/GridData/',
        gridview: false,
        shrinkToFit: false,
        autowidth: true,
        datatype: 'json',
        mtype: 'POST',
        colNames: ['Edit',
                   'MRN',
                   'Hospital Fin',
                   'First Name',
                   'Last Name',
                   'Date of birth',
                   'Completed Pathway',
                   'Completed Pathway Reason',
                   'PCP Appointment',
                   'Specialist Appointment',
                   'Admit Date',
                   'Discharge Date',
                   'Discharge Disposition',
                   'Discharge To',
                   'Discharge Advocate Call',
                   'Home Healthcare',
                   'Safe Landing Accepted',
                   'PCP Name',
                   'PCP Phone',
                   'PCP Appointment Location',
                   'Specialist Name',
                   'Specialist Phone',
                   'Specialist Appointment Location',
                   'Comments',
                   'Patient Room Phone',
                   'Phone',
                   'Payor',
                   'MRN Type'
                   ],
        colModel: [
                   { name: 'Edit', width: 95, align: 'left' },
                   { name: 'MRN', width: 125, align: 'left' },
                   { name: 'Hospital_Fin', width: 145, align: 'left' },
                   { name: 'First_Name', width: 115, align: 'left' },
                   { name: 'Last_Name', width: 115, align: 'left' },
                   { name: 'Date_of_birth', width: 145, align: 'left' },
                   { name: 'Completed_Pathway', width: 125, align: 'left' },
                   { name: 'Completed_Pathway_Reason', width: 165, align: 'left' },
                   { name: 'PCP_Appointment', width: 115, align: 'left' },
                   { name: 'Specialist_Appointment', width: 125, align: 'left' },
                   { name: 'Admit_Date', width: 185, align: 'left' },
                   { name: 'Discharge_Date', width: 185, align: 'left' },
                   { name: 'Discharge_Disposition', width: 155, align: 'left' },
                   { name: 'Discharge_To', width: 85, align: 'left' },
                   { name: 'Discharge_Advocate_Call', width: 155, align: 'left' },
                   { name: 'Home_Health_Care_Accepted', width: 105, align: 'left' },
                   { name: 'Safe_Landing_Accepted', width: 165, align: 'left' },
                   { name: 'PCP_Name', width: 85, align: 'left' },
                   { name: 'PCP_Phone', width: 85, formatter: formatPhoneNumber, align: 'left' },
                   { name: 'PCP_Appointment_Location', width: 185, align: 'left' },
                   { name: 'Specialist_Name', width: 195, align: 'left' },
                   { name: 'Specialist_Phone', width: 135, formatter: formatPhoneNumber, align: 'left' },
                   { name: 'Specialist_Appointment_Location', width: 185, align: 'left' },
                   { name: 'Comments', width: 185, align: 'left' },
                   { name: 'Patient_Room_Phone', width: 135, formatter: formatPhoneNumber, align: 'left' },
                   { name: 'Phone', width: 125, formatter: formatPhoneNumber, align: 'left' },
                   { name: 'Payor', width: 155, align: 'left' },
                   { name: 'MRN_Type', width: 135, align: 'left' }
                   ],
        //pager: jQuery('#pager'),
        rowNum: 10,
        rowList: [5, 10, 20, 50],
        sortname: 'Id',
        sortorder: "desc",
        viewrecords: true,
        imgpath: '/scripts/themes/coffee/images',
        caption: 'My first grid'
    });
}

我需要数据在某个时候异步地返回给我。但在这一点上,乞丐是不可能被选择的。我需要弄清楚为什么我无法获得正确的路由信息。

这是按钮,而不是表单。
它没有
操作


你应该处理表单的
submit
事件,这样
这个
就是表单。

顺便说一句,你知道在jqGrid中异步加载Json数据吗?