标签:
一、无法修改
详情:每次执行修改时,总会显示“错误代码....",
解决:排错时发现是代码执行到 success ,在判断if(data.resultCode==getOption("resultcode_success"))条件语句时进入到else。分别用alert()输出data.resultCode和getOption("resultcode_success"),的结果是分别success和0.
同时用$("#submenu_info").html(fullurl);发现页面显示的数据中"resultCode":success,因为通知java程序员让他在后台把resultCode结果设置为0。
修改部分代码如下:
modal.find(‘form‘).on(‘submit‘, function(ev){ ev.preventDefault(); params["plan_name"]=enURI($("#plan_name").val()); params["description"]=enURI($("#description").val()); params["organization"]=JSON.parse($("#o_id").val()); params["layout"]=JSON.parse($("#l_id").val()); params["animate"]=JSON.parse($("#animates").val()); params["display_time"]=$("#display_time").val(); params["layout"].viewItems=null; params["flag"]=1; params=JSON.stringify(params); //params=params.replace(/\\/g,‘‘); var fullurl=getOption("gykj_host")+type+"/edit"+"?"+getOption("gykj_callbackparam")+"="+getOption("gykj_callbackfunc")+"&token="+getStorage("token")+"&"+type+"="+params; $("#submenu_info").html(fullurl); $.ajax({ url:fullurl, type:‘get‘, dataType:"jsonp", jsonp:getOption("gykj_callbackparam"), jsonpCallback:getOption("gykj_callbackfunc"), async:false, error:function(){ alert("修改:"+getOption("connectionErrorMessage")); }, success:function(data){ if(data.resultCode==getOption("resultcode_success")){ alert(data.message); setListTable(nowpage); }else{ alert("错误代码"+data.errorCode+":"+data.message); setListTable(nowpage); } } }); //ajax modal.remove(); });//submit
二:无法删除
详情:确认删除后,总是显示删除不成功信息。说明执行了error
解决:在一展莫愁之际,同事一句话提醒了我,既然能编辑,肯定能删除,你分别输出编辑代码数据和删除代码数据,看有什么不同。
因此我在两个函数的fullurl地址后面,分别插入$("#submenu_info").html(fullurl);代码,
发现编辑中显示如下
http://59.39.60.226:81/Weather/plan/edit?callback=jsonp&token=34e59752-c53c-4b06-af56-8bf0e1271433&plan={"plan_id":6,"plan_name":"22","display_time":"7","order":null,"description":"8","organization":{"o_id":2,"o_name":"组织结构名称","logo":"","description":"描述erytreyss113"},"layout":{"l_id":3,"l_name":"生活指数","l_type":null,"picture":null,"viewItems":null},"animate":{"a_id":2,"a_name":"push_left","description":"push_left"},"flag":1}
而删除代码则显示
http://59.39.60.226:81/Weather/plan/edit?callback=jsonp&token=34e59752-c53c-4b06-af56-8bf0e1271433&plan={"plan_id":6,"plan_name":"22","display_time":7,"order":null,"description":"8","organization":{"o_id":2,"o_name":"组织结构名称","logo":"","description":"描述erytreyss113"},"layout":{"l_id":3,"l_name":"生活指数","l_type":null,"picture":null,"viewItems":[{"vi_id":565,"parent_id":563,"viewItems":[],"type":"LinearLayout_h","weight":1,"order":2,"background_type":3,"background":"00ff0000","textsize":30,"textcolor":"ffff0000","structure":"","gravity":"center|center","font_family":"yahei","font_style":null,"width":"0","height":"match_parent","display_time":0,"padding":"(5,5,5,5)","margin":"(0,0,0,0)","filepath":"","filemd5":"","scaletype":"","flag":1,"animate":{"a_id":1,"a_name":"无","description":"无"}},{"vi_id":587,"parent_id":570,"viewItems":[],"type":"LinearLayout_v","weight":70,"order":2,"background_type":3,"background":"00ff0000","textsize":30,"textcolor":"ffff0000","structure":"","gravity":"center|center","font_family":"yahei","font_style":null,"width":"0","height":"match_parent","display_time":0,"padding":"(5,5,5,5)","margin":"(0,0,0,0)","filepath":"","filemd5":"","scaletype":"","flag":1,"animate":{"a_id":1,"a_name":"无","description":"无"}},{"vi_id":566,"parent_id":563,"viewItems":[],"type":"LinearLayout_h","weight":1,"order":3,"background_type":3,"background":"00ff0000","textsize":30,"textcolor":"ffff0000","structure":"","gravity":"center|center","font_family":"yahei","font_style":null,"width":"0","height":"match_parent","display_time":0,"padding":"(5,5,5,5)","margin":"(0,0,0,0)","filepath":"","filemd5":"","scaletype":"","flag":1,"animate":{"a_id":1,"a_name":"无","description":"无"}},{"vi_id":606,"parent_id":591,"viewItems":[],"type":"TextView","weight":1,"order":1,"background_type":3,"background":"00ff0000","textsize":25,"textcolor":"ffffffff","structure":"zhishu.data.data.3.type","gravity":"center|center","font_family":"yahei","font_style":null,"width":"match_parent","height":"0","display_time":0,"padding":"(5,5,5,5)","margin":"(0,0,0,0)","filepath":"","filemd5":"","scaletype":"","flag":1,"animate":{"a_id":1,"a_name":"无","description":"无"}},{"vi_id":568,"parent_id":564,"viewItems":[],"type":"LinearLayout_h","weight":1,"order":1,"background_type":3,"background":"781400ff","textsize":30,"textcolor":"ffff0000","structure":"","gravity":"center|center","font_family":"yahei","font_style":null,"width":"0","height":"match_parent","display_time":0,"padding":"(5,5,5,5)","margin":"(0,0,0,0)","filepath":"","filemd5":"","scaletype":"","flag":1,"animate":{"a_id":1,"a_name":"无","description":"无"}},{"vi_id":569,"parent_id":564,"viewItems":[],"type":"LinearLayout_h","weight":1,"order":2,"background_type":3,"background":"781400ff","textsize":30,"textcolor":"ffff0000","structure":"","gravity":"center|center","font_family":"yahei","font_style":null,"width":"0","height":"match_parent","display_time":0,"padding":"(5,5,5,5)","margin":"(0,0,0,0)","filepath":"","filemd5":"","scaletype":"","flag":1,"animate":{"a_id":1,"a_name":"无","description":"无"}},{"vi_id":585,"parent_id":568,"viewItems":[],"type":"LinearLayout_v","weight":70,"order":2,"background_type":3,"background":"00ff0000","textsize":30,"textcolor":"ffff0000","structure":"","gravity":"center|center","font_family":"yahei","font_style":null,"width":"0","height":"match_parent","display_time":0,"padding":"(5,5,5,5)","margin":"(0,0,0,0)","filepath":"","filemd5":"","scaletype":"","flag":1,"animate":{"a_id":1,"a_name":"无","description":"无"}},{"vi_id":588,"parent_id":571,"viewItems":[],"type":"LinearLayout_v","weight":70,"order":2,"background_type":3,"background":"00ff0000","textsize":30,"textcolor":"ffff0000","structure":"","gravity":"center|center","font_family":"yahei","font_style":null,"width":"0","height":"match_parent","display_time":0,"padding":"(5,5,5,5)","margin":"(0,0,0,0)","filepath":"","filemd5":"","scaletype":"","flag":1,"animate":{"a_id":1,"a_name":"无","description":"无"}},{"vi_id":595,"parent_id":585,"viewItems":[],"type":"TextView","weight":1,"order":2,"background_type":3,"background":"00ff0000","textsize":30,"textcolor":"ffff0000","structure":"zhishu.data.data.4.description","gravity":"center|center","font_family":"yahei","font_style":null,"width":"match_parent","height":"0","display_time":0,"padding":"(5,5,5,5)","margin":"(0,0,0,0)","filepath":"","filemd5":"","scaletype":"","flag":1,"animate":{"a_id":1,"a_name":"无","description":"无"}},{"vi_id":599,"parent_id":587,"viewItems":[],"type":"TextView","weight":1,"order":2,"background_type":3,"background":"00ff0000","textsize":30,"textcolor":"ffffffff","structure":"zhishu.data.data.8.description","gravity":"center|center","font_family":"yahei","font_style":null,"width":"match_parent","height":"0","display_time":0,"paddi.................
经过对比,发现viewItems显示的数据太多,在编辑代码中params["layout"].viewItems=null;,viewItems的数据是为null,因此把这句代码也复制到删除代码中,问题解决。
原删除代码如下:
function deleteInfo(type,item){ var params=datarecords[item]; if(confirm("您确认要删除吗?")){ params["flag"]=0; params=JSON.stringify(params); var fullurl=getOption("gykj_host")+type+"/edit"+"?"+getOption("gykj_callbackparam")+"="+getOption("gykj_callbackfunc")+"&token="+getStorage("token")+"&"+type+"="+params; $("#submenu_info").html(fullurl); $.ajax({ url:fullurl, type:‘get‘, dataType:"jsonp", jsonp:getOption("gykj_callbackparam"), jsonpCallback:getOption("gykj_callbackfunc"), async:false, error:function(){ alert("删除:"+getOption("connectionErrorMessage")); }, success:function(data){ if(data.resultCode==getOption("resultcode_success")){ //alert(data.message); setListTable(nowpage); }else{ alert("错误代码"+data.errorCode+":"+data.message); setListTable(nowpage); } } }); } }
修改后代码
function deleteInfo(type,item){ var params=datarecords[item]; if(confirm("您确认要删除吗?")){ params["layout"].viewItems=null; params["flag"]=0; params=JSON.stringify(params); var fullurl=getOption("gykj_host")+type+"/edit"+"?"+getOption("gykj_callbackparam")+"="+getOption("gykj_callbackfunc")+"&token="+getStorage("token")+"&"+type+"="+params; $("#submenu_info").html(fullurl); $.ajax({ url:fullurl, type:‘get‘, dataType:"jsonp", jsonp:getOption("gykj_callbackparam"), jsonpCallback:getOption("gykj_callbackfunc"), async:false, error:function(){ alert("删除:"+getOption("connectionErrorMessage")); }, success:function(data){ if(data.resultCode==getOption("resultcode_success")){ //alert(data.message); setListTable(nowpage); }else{ alert("错误代码"+data.errorCode+":"+data.message); setListTable(nowpage); } } }); } }
信息发布平台(Bootstrap ace)--$.ajax()无法修改及删除
标签:
原文地址:http://www.cnblogs.com/mailan/p/4843796.html