/** * 订单取消 * @return {Boolean} 处理是否成功 */ function orderCancel(orderId,commant){ var flag = false; $.ajax({ type: "POST",url: "../order/orderCancel.action",//orderModifyStatus <span style="color:#ff0000;"><strong>①</strong></span><strong><span style="color:#ff0000;"> data: {"orderId":orderId,"commant":commant},</span></strong> dataType:"json",async:false,cache:false,success: function(data){ var member = eval("("+data+")"); //包数据解析为json 格式 if(member.success=="true"){ flag = true; }else if(member.success=="false") { alert(member.info); } },error: function(json){ alert("订单取消异常,请刷新后重试..."); } }); hidediv(); return flag; }
② data: "orderId=" + orderId + "&commant=" + commant
乱码解决:
发生情况,项目的编码方式为gbk,页面的编码是gbk,使用ajax进行传值的过程中出现了乱码,解决的步骤如下,供参考。
var url="addPatternInfo.action"; var params={ "patternInfo.Area_name":<strong><span style="color:#ff0000;">encodeURI(area_name)</span></strong>,"patternInfo.name1":encodeURI(name1) }; $.ajax({ async:false,type:"post",url:url,data:params,dataType:"json",<span style="color:#ff0000;"><strong>contentType:'application/x-www-form-unlencoded;charset=UTF-8',</strong></span> cache:false,success:function(data){ alert("OK"); } });
服务器端
patternInfo.setName1(URLDecoder.decode(patternInfo.getName1(),"UTF-8"));