You don't need to use a response for create, delete and update.
E.g. if you do an create operation you are calling an "ajax operation" which adds your data into a database.
There are now two possibilites:
- Create Operation succeeds
- just return nothing, means empty string
- (as long as a 200 response is received by jqgrid, everything is fine)
- Create Operation failed
- just throw an Exception with a modified response header
If jqGrid receives an non 200 response code it shows you an error itself!
try {
// insert something in your db
// ok = true means everything fine
// ok = false means something unpredictable happened
if (!$ok) {
throw new Exception('error');
}
} catch (Exception $e) {
header("Status: 500 Server Error caused by dbinsert jqgrid");
var_dump($e->getMessage());
}
Sorry for the code, but it was the fastest I get out of my brain now :)
I use jqGrid in combination with the Zend Framework and ZF uses 500 Response codes for Exceptions by default (at least my template)
After a successful update/delete/create you have to refetch the whole jqGrid data.
jQuery("#your_jqgrid_id").jqGrid().trigger('reloadGrid');
There is afaik no other mechanism. (Used it last about 6 months ago, maybe that changed)
If you want to implement your own error/success handling, just define your own message in whatever format you want and handle it in the ajax success function callback.
If you need more code and it is not urgent, just drop me a comment.
One additional advice: Don't expect to understand jqGrid immediatly. Take your time, try some things, play with it. It will take some time before you feeling comfortable with it.