jqgrid添加、编辑、删除 客户端怎么接受后台返回的状态信息

988kook 2012-07-31 04:59:56
RT

 editurl: "Data/Edit.ashx", //增删改的页面


我用的是jqgrid本身的增删改查

我添加了一条记录 在后台post方式接受到

然后修改数据 比如修改失败了,客户端怎么接受错误信息

我返回 json state:success/state:error或者sucess/error均没有反应
...全文
439 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Go 旅城通票 2012-08-01
  • 打赏
  • 举报
回复
jqgrid的api编写不怎么好,不知道从哪里看起,Demo也不友好,全部php动态页,建议你还是用jquery.easyui的datagrid,出问题了好解决。


大概看了下jqgrid的api,好像说要自己处理原始的xhr返回的数据,然后return信息

afterSubmit:fires after response has been received from server. Typically used to display status from server (e.g., the data is successfully saved or the save cancelled for server-side editing reasons). Receives as parameters the data returned from the request and an array of the posted values of type id=value1,value2.
When used this event should return array with the following items [success, message, new_id]
where
success is a boolean value if true the process continues, if false a error message appear and all other processing is stopped. (message is ignored if success is true).
new_id can be used to set the new row id in the grid when we are in add mode.
afterSubmit : function(response, postdata)
{

return [success,message,new_id]
}


如果没理解错,应该是添加afterSubmit事件,自己处理ajax返回的内容,然后return指定规格的数据

afterSubmit : function(response, postdata)
{
var r=eval('('+response.responseText+')')//动态页返回json格式的字符串,如{success:true/false}之类的,为false添加err属性什么的,成功则返回new_id
return [r.success,r.message,r.new_id]
}

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧