資訊發布平台(Bootstrap ace)--$.ajax()無法修改及刪除

來源:互聯網
上載者:User

標籤:

一、無法修改

詳情:每次執行修改時,總會顯示“錯誤碼....",

解決:排錯時發現是代碼執行到 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()無法修改及刪除

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.