Jqgrid自定义按钮发送POST数据

我使用thos代码:

jQuery("#rowed2").jqGrid({ url:'server.php?q=3', datatype: "json", colNames:['Acc','Id','Ciudad', 'Corporacion','Radicado','Ultima Actuacion','Anotaciones'], colModel:[ {name:'act',index:'act', width:72, sortable:false}, {name:'id',index:'id', width:31}, {name:'ciudadh',index:'ciudadh', width:100, editable:true}, {name:'corporacionh',index:'corporacionh', width:350, align:"right",editable:true,fixed:true }, {name:'radicado',index:'radicado', width:190, align:"right",editable:true}, {name:'ultima',index:'ultima', width:160,align:"right",editable:true}, {name:'anotaciones',index:'anotaciones', width:200, sortable:false,editable:true} ], rowNum:200, rowList:[10,20,30], imgpath: 'css', pager: jQuery('#prowed2'), sortname: 'actionID', viewrecords: true, sortorder: "desc", height: "100%", loadComplete: function(){ $("tr.jqgrow:odd").addClass('myAltRowClass'); var ids = jQuery("#rowed2").getDataIDs(); for(var i=0;i<ids.length;i++){ var cl = ids[i]; be = "
"; se = "
"; ce = ""; send = "
"; clear = "
"; jQuery("#rowed2").setRowData(ids[i],{act:be+se+ce,anotaciones:send+clear}) } $(".sendbuttons").click(function(){ alert("got to 1"); }); }, editurl: "server2.php" }); //botonañadir $("#bedata").click(function(){ jQuery("#rowed2").jqGrid('editGridRow',"new",{height:380,reloadAfterSubmit:false}); }); //botonborrar $("#bedata2").click(function(){ var gr = jQuery("#rowed2").jqGrid('getGridParam','selrow'); if( gr != null ) jQuery("#rowed2").jqGrid('delGridRow',gr, {reloadAfterSubmit:false}); else alert("Antes de hacer clic en este boton seleccione el proceso que desea borrar!"); }); var timeoutHnd; var flAuto = false; function doSearch(ev){ if(!flAuto) return; // var elem = ev.target||ev.srcElement; if(timeoutHnd) clearTimeout(timeoutHnd) timeoutHnd = setTimeout(gridReload,500) } function gridReload(){ var nm_mask = jQuery("#item").val(); var cd_mask = jQuery("#search_cd").val(); jQuery("#rowed2").jqGrid('setGridParam',{url:"server.php? nm_mask="+nm_mask+"&cd_mask="+cd_mask,page:1}).trigger("reloadGrid"); } function enableAutosubmit(state){ flAuto = state; jQuery("#submitButton").attr("disabled",state); }

所以我这个按钮

  send = "
";

可以通过post发送一些数据,就像这个按钮一样:

  be = "
"; se = "
"; ce = "";

例如,我的自定义按钮可以使用其他参数发送和调用“custom”。

那可能吗? 怎么样?

谢谢你的帮助。

更新:

我正在尝试像这样做一个ajax函数:

  $(".sendbuttons").click(function(){ $.ajax({ type:'POST', url :'server2.php?id=+ids[i]+&oper=edit1', beforeSend : function(){ $('#mensaje5').show().html('

Por favor espere....
cargando'); }, success: function (){ var nancu = parseInt(ids); alert(mega); ; }, complete: function(){ $('#form_data4').slideUp(); } }); });

对我的需求似乎是一个好主意,但我对这一行有一个问题:

  url :'server2.php?id=+ids[i]+&oper=edit1', 

我想获取按钮行的id,然后通过post在url中发送此id,但我不知道如何做到这一点。

试试这个

更改此send = "
";

 send = "
";

并在Jquery主函数外添加一个新函数

 ' function send(id) $.ajax({ type:'POST', url :'server2.php?id='+id+'&oper=edit1', beforeSend : function(){ $('#mensaje5').show().html('

Por favor espere....
cargando'); }, success: function (){ var nancu = parseInt(ids); alert(mega); ; }, complete: function(){ $('#form_data4').slideUp(); } });}'