通过MVC3上的Ajax请求调用jqgrid时出错:错误80020101

时间:2013-03-22 08:32:52

标签: jquery asp.net-mvc-3

以下代码引发错误,例如“由于错误80020101无法完成操作”

文件jquery-1.8.3.js上的

<script language="javascript" type="text/javascript">

    $(document).ready(function () {
        var Details = '@Url.Content("~/Controller/ActionResult1?id=")';

        var id= $("#id").val();
        $('#pager').hide();

        Details = Details + id;

        alert(PropertyDetails);
        $("#list").jqGrid({

            url: Details,
            datatype: 'xml',
            cache: false,
            mtype: 'GET',
            width: 600,
            height: 234,
            colNames: ['Name', 'Address', 'Type'],
            colModel: [
            { name: 'Name', index: 'Name', width: 20, xmlmap: 'Name' },
            { name: 'Address', index: 'Address', width: 20, xmlmap: 'Address' },
            { name: 'Type', index: 'Type', width: 20, xmlmap: 'Type' },
            ],

            xmlReader: { repeatitems: false },
            pager: '#pager',
            rowNum: 10,
            sortname: 'invid',
            sortorder: 'desc',
            viewrecords: true,
            gridview: true,
            loadonce: true,
            shrinkToFit: true,
            scroll: false,
            altRows: true,
            loadComplete: function () {
                if ($('#list').getGridParam('records') > 10) {
                    $('#pager').show();
                }
            }

        });

    });

    </script>

<table id="list"><tr><td/></tr></table> 
<div id="pager"></div>  

my controller side.

 public ActionResult ActionResult1(string id)
        {
// code
}

1 个答案:

答案 0 :(得分:1)

像这样修改脚本:

<script language="javascript" type="text/javascript">

    $(document).ready(function () {
         var Details = '@Url.Content("~/Controller/ActionResult1?id=';

         var id= $("#id").val();
         $('#pager').hide();

         Details = Details + id+'")';


        alert(PropertyDetails);
        $("#list").jqGrid({

            url: Details,
            datatype: 'xml',
            cache: false,
            mtype: 'GET',
            width: 600,
            height: 234,
            colNames: ['Name', 'Address', 'Type'],
            colModel: [
            { name: 'Name', index: 'Name', width: 20, xmlmap: 'Name' },
            { name: 'Address', index: 'Address', width: 20, xmlmap: 'Address' },
            { name: 'Type', index: 'Type', width: 20, xmlmap: 'Type' },
            ],

            xmlReader: { repeatitems: false },
            pager: '#pager',
            rowNum: 10,
            sortname: 'invid',
            sortorder: 'desc',
            viewrecords: true,
            gridview: true,
            loadonce: true,
            shrinkToFit: true,
            scroll: false,
            altRows: true,
            loadComplete: function () {
                if ($('#list').getGridParam('records') > 10) {
                    $('#pager').show();
                }
            }

        });

    });

    </script>