Jqgrid does not restart after ajax call with trigger ('reload')

I am trying to reload the grid with new data that has just been changed so that the user can see the new data with the changes.

my approach:

jQuery("#relCasePick").click( function(){ var ids=jQuery("#list10").jqGrid('getGridParam','selarrrow'); $.ajax({ type: "POST", url: "/cpsb/unprocessedOrders.do?method=releaseToCasePick&orderNumbers="+ids, data: JSON.stringify(ids), dataType: "json" }); jQuery("#list10").setGridParam({rowNum:10,datatype:"json"}).trigger('reloadGrid'); }); 

when i click this button. I am sending the data correctly, but when I reload it, I am not updated with the new data .... I would really appreciate it if someone could help.

+4
source share
1 answer

What I see here is an Ajax call to publish, and the other is a grid reload. The problem here is which ajax call will be completed first ?. You do not know. It would be best to use the success callback function in an Ajax post. This will reload the grid if and only if the message is successful.

 jQuery("#relCasePick").click( function(){ var ids =jQuery("#list10").jqGrid('getGridParam','selarrrow'); $.ajax({ type: "POST", url: "/cpsb/unprocessedOrders.do?method=releaseToCasePick&orderNumbers="+ids, data: JSON.stringify(ids), dataType: "json", success: function(data) { jQuery("#list10").setGridParam({rowNum:10,datatype:"json" }).trigger('reloadGrid'); } }); }); 
+4
source

All Articles