Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用context.request获取json数据时出现问题_Javascript_Jquery_Json_Twitter Bootstrap_Jqgrid - Fatal编程技术网

Javascript 使用context.request获取json数据时出现问题

Javascript 使用context.request获取json数据时出现问题,javascript,jquery,json,twitter-bootstrap,jqgrid,Javascript,Jquery,Json,Twitter Bootstrap,Jqgrid,我正在使用bootstrap开发一个基于web的应用程序。 我试图在页面加载时在网格中实现内联编辑,但在处理json数据时遇到了一些问题 这是我的代码: $(document).ready(function () { var GetUrl = Web_Path + '/Test/TestHandler/GetTestData/' + AjaxHandlerName; jQuery("#jqGrid-container").jqGrid({

我正在使用bootstrap开发一个基于web的应用程序。 我试图在页面加载时在网格中实现内联编辑,但在处理json数据时遇到了一些问题

这是我的代码:

  $(document).ready(function () {
    var GetUrl = Web_Path + '/Test/TestHandler/GetTestData/' + AjaxHandlerName;

                jQuery("#jqGrid-container").jqGrid({
                    url: GetUrl,
                    datatype: 'json',
                    mtype: 'POST',
                    postData: { SearchInfo: function () { return getSearchPostData() } },
                    colNames: [' ', 'ID', 'Name', 'ContactNo', 'EmpId', 'MailId', 'RoleName'],
                    colModel: [
                    { name: 'myac', index: '', width: 80, fixed: true, sortable: false, resize: false,
                        formatter: 'actions',
                        formatoptions: {
                            keys: true,
                            delOptions: { recreateForm: true, beforeShowForm: beforeDeleteCallback }
                        }
                    },
                                { name: 'Id', index: 'Id', hidden: true, editable: true },
                                { name: 'Name', index: 'Name', validation: { required: true }, sortable: true, editable: true, editoptions: { size: "40", maxlength: "50"} },
                                { name: 'ContactNo', index: 'ContactNo', sortable: false, editable: true, editoptions: { size: "20", maxlength: "30"} },
                                { name: 'EmpId', index: 'EmpId', sortable: false, editable: true, editoptions: { size: "20", maxlength: "30"} },
                                { name: 'MailId', index: 'MailId', sortable: false, editable: true, editoptions: { size: "40", maxlength: "50"} },
 {name: 'RoleName', index: 'RoleName', sortable: false }
  ],


                    editurl: ISM_Web_Path + '/Test/TestHandler/UpdateTestContacts/' + ISMAjaxHandlerName,                 

                    ajaxRowOptions: {
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json"
                    },                 
                    serializeRowData: function (postdata) {
                    return { ContactInfo: JSON.stringify(postdata) };                     
                    },
                    jsonReader: {
                        id: 'Id',
                        repeatitems: false
                    },
                    height: "100%",
                    pager: '#jqGrid-pager',
                    rowNum: 10,
                    rowList: [10, 20, 30],
                    sortname: 'Id',
                    sortorder: 'desc',
                    viewrecords: true,
                    caption: "JQ grid data",
                    loadComplete: function () {
                        var table = this;
                        updatePagerIcons(table);                       
                    }
                });
});

 function getSearchPostData() {
            var searchData = {};
            searchData.Id=1;

            return JSON.stringify(searchData);
        }
 function updatePagerIcons(table) {
            var replacement =
                    {
                        'ui-icon-seek-first': 'icon-double-angle-left bigger-140',
                        'ui-icon-seek-prev': 'icon-angle-left bigger-140',
                        'ui-icon-seek-next': 'icon-angle-right bigger-140',
                        'ui-icon-seek-end': 'icon-double-angle-right bigger-140'
                    };
            $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function () {
                var icon = $(this);
                var $class = $.trim(icon.attr('class').replace('ui-icon', ''));

                if ($class in replacement) icon.attr('class', 'ui-icon ' + replacement[$class]);
            })
}

 <div class="row">
        <div class="col-xs-12">           
            <table id="jqGrid-container" class="ui-jqgrid ui-widget ui-widget-content ui-corner-all">
            </table>
            <div id="jqGrid-pager">
            </div>           
        </div>
    </div>
TestContact.cs

 public class TestContact
    {
        public int Id { get; set; }

        public string Name { get; set; }

        public string ContactNo { get; set; }

        public string EmpId { get; set; }

        public int RelId { get; set; }

        public int TypeId { get; set; }

        public string MailId { get; set; }

        public string RoleName { get; set; }       
    }
我使用了jquery.jqGrid.min.js

我正在获取,错误ArgumentNullException由用户代码处理。字符串引用未设置为字符串的实例。 参数名称:s字符串jsonData=context.Request.Params[“ContactInfo”]


请帮帮我。

它已经是JSon类型的,所以我已经从代码中删除了以下几行

 ajaxRowOptions: {
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json"
                    }
它很好用

 ajaxRowOptions: {
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json"
                    }