Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.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
Jquery jqgrid OnComplete运行的函数不工作_Jquery_Jqgrid - Fatal编程技术网

Jquery jqgrid OnComplete运行的函数不工作

Jquery jqgrid OnComplete运行的函数不工作,jquery,jqgrid,Jquery,Jqgrid,我试图在jqgrid将数据从服务器输入网格后运行一个函数。被调用的函数将csrf令牌更新为下一个jqgrid请求的全局变量 $("#customer_grid").jqGrid({ mtype: 'POST', url:'jqgrid/customer', postData: { <?php echo $csrf_token_name; ?>: csrf_token }, datatype: 'json', colNames:['Account

我试图在jqgrid将数据从服务器输入网格后运行一个函数。被调用的函数将csrf令牌更新为下一个jqgrid请求的全局变量

$("#customer_grid").jqGrid({
    mtype: 'POST',
    url:'jqgrid/customer',
    postData: { <?php echo $csrf_token_name; ?>: csrf_token },
    datatype: 'json',
    colNames:['Account #', 'Firstname', 'Surname','Postcode','Address 1','Address 2', 'Address 3', 'City', 'County',
                'Country', 'Email', 'Home Tel', 'Mobile Tel', 'Work Tel'],
    colModel :[
      {name:'id', index:'id', width:80},
      {name:'firstname', index:'firstname', width:80},
      {name:'surname', index:'surname', width:80},
      {name:'postcode', index:'postcode', width:80},
      {name:'address_1', index:'address_1', width:80},
      {name:'address_2', index:'address_2', width:80},
      {name:'address_3', index:'address_3', width:80},
      {name:'city', index:'city', width:80},
      {name:'county', index:'county', width:80},
      {name:'country', index:'country', width:65},
      {name:'email', index:'email', width:80},
      {name:'home_tel', index:'home_tel', width:80},
      {name:'mobile_tel', index:'mobile_tel', width:80},
      {name:'work_tel', index:'work_tel', width:80},
    ],
    emptyRecords: "No Accounts Found",
    pager: '#customer_grid_pager',
    rowNum:10,
    rowList:[5,10,25,50,100],
    rownumbers: true,
    sortname: 'id',
    sortorder: 'desc',
    viewrecords: true,
    gridview : true,
    caption: 'Customer Search',
    height: '220',
    autowidth: true,
    onComplete: function(data, response) {
          get_csrf_token();
          alert(csrf_token);
    },
    ondblClickRow: function(id, row, column){              
          //alert('Hello World '+ id + ' ' + row + ' ' + column);
          customer_id = id;
          //alert(customer_id);
          crud_action = 'update';
          $('#new_customer').show();
          $('#customer_search').hide();
          customer_crud('read');
          show('#details');
    }



  });
$(“客户网格”).jqGrid({
mtype:“POST”,
url:'jqgrid/customer',
postData:{:csrf_token},
数据类型:“json”,
colNames:['Account#','Firstname','姓氏','Postcode','Address 1','Address 2','Address 3','City','country',
“国家”、“电子邮件”、“家庭电话”、“移动电话”、“工作电话”],
colModel:[
{名称:'id',索引:'id',宽度:80},
{name:'firstname',索引:'firstname',宽度:80},
{名称:'姓氏',索引:'姓氏',宽度:80},
{名称:'postcode',索引:'postcode',宽度:80},
{名称:'address_1',索引:'address_1',宽度:80},
{名称:'address_2',索引:'address_2',宽度:80},
{名称:'address_3',索引:'address_3',宽度:80},
{名称:'city',索引:'city',宽度:80},
{名称:'county',索引:'county',宽度:80},
{名称:'country',索引:'country',宽度:65},
{名称:'email',索引:'email',宽度:80},
{名称:'home\u tel',索引:'home\u tel',宽度:80},
{名称:'mobile_-tel',索引:'mobile_-tel',宽度:80},
{名称:'work_-tel',索引:'work_-tel',宽度:80},
],
emptyRecords:“未找到任何帐户”,
寻呼机:“#客户_网格_寻呼机”,
rowNum:10,
行列表:[5,10,25,50100],
行数:对,
sortname:'id',
排序器:“desc”,
viewrecords:是的,
gridview:没错,
标题:“客户搜索”,
高度:'220',
自动宽度:正确,
onComplete:功能(数据、响应){
获取_csrf_令牌();
警报(csrf_令牌);
},
ondblClickRow:函数(id、行、列){
//警报(“Hello World”+id+“”+行+“”+列);
客户id=id;
//警报(客户标识);
crud_操作=‘更新’;
$(“#新客户”).show();
$(“#客户搜索”).hide();
客户积垢(“读取”);
显示(“#细节”);
}
});
Firebug没有显示javascript错误,get_csrf_token()也没有被调用,有什么想法吗


谢谢

我没有看到
onComplete
被列为。您确定不是要使用
gridComplete
loadComplete

您应该使用这个
gridComplete:函数(数据、响应){
获取_csrf_令牌();
警报(csrf_令牌);

},

您可以发布get\u csrf\u token()函数吗?@ithcy get\u csrf\u token()使用get从我询问的服务器检索令牌,因为如果该函数中存在语法错误,您的jqGrid代码可能无法计算。但我认为这不是问题所在。看看我的答案。