使用$ .get方法传递Serializated参数在控制器方法中返回null

时间:2013-11-20 10:32:36

标签: jquery json model-view-controller serialization

我已使用MVC 4.0中的$ .get方法将序列化对象作为参数传递

$('#btnGenerateReport').click(function () {
    // get filter data
    var reportType = $('input[name=rtype]:radio:checked').val();
    var towerlist = '',
        streamList = '',
        resourceList = '',
        projectList = '';
    $("#selectTower").multiselect("getChecked").each(function (index, object) {
        towerlist = towerlist + $(object).val() + ','
    });

    var o = new Object();
    o.TowerId = towerlist;    

    $.get('@Url.Action("Resource", "Report")', {
        'filterList': JSON.stringify(o)
    }, function (data) {
        $('#report').replaceWith(data);
        $('div.well').hide();
    });
});

但它始终在控制器方法

中返回filterList null
 public ActionResult Resource(ResourceReport filterList)
    {
        var t = filterList.TowerId;
        var report = resourceReportService.GetResourceReport();
        return View("ResourceReport",report);
    }

我已添加using System.Web.Script.Serialization;命名空间

0 个答案:

没有答案