Jquery Ajax 异步请求
Ajax异步请求Code示例:
$.ajax( { type : "post", // 查询所有区县 url : 'transType.action', async : false, dataType : "json", data : { "sCity" : startCityCode, "aCity" : arrivedCityCode, "sArea" : startAreaCode, "aArea" : arrivedAreaCode }, success : function(data) { if (data == null || data.length == 0) { cleanTransportTable(); $("#errTxt").text("未查找到运输路线"); return; } else { if (data.pricelist.length == 0) { cleanTransportTable(); $("#errTxt").text("未查找到运输路线"); return; } pricePlanBean = data.pricelist; count = data.count; isPilotCityOfA = data.isPilotCityOfA; hasAgentCityOfA = data.hasAgentCityOfA; orgCount = data.orgCount; //获取出发城市,到达城市,城市code,区域code departureCity = data.departureCity; destinationCity = data.destinationCity; destinationArea=data.destinationArea; departureArea=data.departureArea; strVolume = _strVolume; weight = _weight; wrap = iswrap; if (data.orgCountOfCounty == 0) { alert("该线路尚未开通,运输方式只能选择汽运偏线"); } $("#createOrder").attr("disabled",""); getTransport();//生成运输类型 } }, error : function(XMLHttpRequest, textStatus, errorThrown) { $("#errTxt").text(""); $("#errTxt").text("网络繁忙,请稍后再试!"); } });
transType.action部分代码:
Map<String, Object> map = new HashMap<String, Object>(); map.put("pricelist", ppi); map.put("count", count); map.put("departureCity", sCity); map.put("destinationCity", aCity); map.put("departureArea", sArea); //出发城市区域code通过JSON传到订单 map.put("destinationArea", aArea);//到达城市区域code通过JSON传到订单 map.put("isPilotCityOfA", isPilot2); //到达城市是否为试点城市 map.put("hasAgentCityOfA", hasAgent); //到达城市是否为落地配城市 map.put("orgCount", orgCount); //到达城市德邦网点数 map.put("orgCountOfCounty", orgCountOfCounty); //到达区县德邦网点数 json = map; return "JSON"; } return "JSON";
相关推荐
kentrl 2020-11-10
结束数据方法的参数,该如何定义?-- 集合为自定义实体类中的结合属性,有几个实体类,改变下标就行了。<input id="add" type="button" value="新增visitor&quo
ajaxyan 2020-11-09
zndy0 2020-11-03
学留痕 2020-09-20
Richardxx 2020-11-09
learningever 2020-09-19
chongxiaocheng 2020-08-16
ajaxhe 2020-08-16
lyqdanang 2020-08-16
curiousL 2020-08-03
TONIYH 2020-07-22
时光如瑾雨微凉 2020-07-19
83510998 2020-07-18
坚持着执着 2020-07-16
jiaguoquan00 2020-07-07
李永毅 2020-07-05
坚持着执着 2020-07-05