jqgrid php demo 代码,php – 遇到jqgrid dataUrl函数代码段的问题

我需要拥有当前选择的行id以构建一个JSON字符串,该字符串将传递给php脚本以创建一个select,因此我将脚本引用和代码包含在一个函数中.

但是,这样做会产生NetworkError:403 Forbidden错误.

这是代码段:

editoptions:{dataUrl:function(){

var row_id = $('#tab3-grid').getGridParam('selrow');

var jsondata = JSON.stringify({"cu.STID": $('#tab3-grid').jqGrid('getCell', row_id, 'cu.STID'),

"wv.SVID": $('#tab3-grid').jqGrid('getCell', row_id, 'wv.SVID')});

return 'php/items-se-script.php?data='+jsondata;

},

有谁知道发生了什么?

更新:

{name:'it.PRID', index:'it.PRID', hidden: true, editable:true, edittype:'select',

editoptions:{dataUrl:'php/items-se-script.php', defaultValue:'26', dataEvents:[{type:'change',fn:function(e){$('input#ip\\.Item').val($('option:selected', this).text());}}]},

formoptions:{label:'Item', elmprefix:'* '},

editrules:{edithidden:true, required:true}},

{name:'ip.Item', index:'ip.Item', hidden: true, sortable: true, editable:false, edittype:'text', editoptions:{readonly:true,size:20}, formoptions:{rowpos: 50, label:'Item'}, editrules:{required:true}}

],

ajaxSelectOptions: {

type:'POST',

data: {

data: function () {

var row_id = $('#tab3-grid').getGridParam('selrow');

return JSON.stringify({

"cu.STID": $('#tab3-grid').jqGrid('getCell', row_id, 'cu.STID'),

"wv.SVID": $('#tab3-grid').jqGrid('getCell', row_id, 'wv.SVID')

});

}

}

},

url: 'php/workordertab-script.php',

editurl:'php/workordertab-script.php',

解决方法:

属性dataUrl不能是一个函数.如果您需要在构建选择期间向服务器发送任何其他信息,您可以使用ajaxSelectOptions选项,就像我描述的here一样.在您的情况下,它将是关于以下内容:

var $myGrid = $('#tab3-grid');

$myGrid.jqGrid({

// ... here all you current parameters which includes

// editoptions: { dataUrl: 'php/items-se-script.php' }

// for the corresponding column in colModel

ajaxSelectOptions: {

data: { // "data" here is jQuery.ajax parameter

data: function () { // "data" here is the name of you custom parameter

var row_id = $myGrid.getGridParam('selrow');

return JSON.stringify({

"cu.STID": $myGrid.jqGrid('getCell', row_id, 'cu.STID'),

"wv.SVID": $myGrid.jqGrid('getCell', row_id, 'wv.SVID')

});

}

}

}

});

标签:php,json,jqgrid

来源: https://codeday.me/bug/20190927/1825041.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值