/* * ajax请求封装 */function _ajax(url,data,callback){ ???try { ???????$.ajax({ ???????????url:url, ???????????type:"POST", ???????????data:data, ???????????dataType:‘json‘, ???????????success:function(data){ ???????????????try { ???????????????????????????????????????????if(data.code == 0){ ?????????????????????????????????????????????????mui.alert(‘保存成功‘) ???????????????????}else{ ???????????????????????????????????????????????mui.toast(‘保存失败‘); ???????????????????} ?????????????????????????????????????} catch(e) { ???????????????????????????????????mui.toast(‘获取数据失败‘); ?????????????????} ???????????}, ???????????error: function(xhr, textStatus, error) { ???????????????????????????????????????if(textStatus == "error") ???????????????mui.toast(‘请检查网络连接‘); ???????????} ???????}); ???????????}catch(e) { ?????????mui.toast("请检查网络连接"); ???????}}/* * ajax调用 */var webUrl = G_WEBBASE + "rcall.jsp?sytid=CHIS&mwid=GZJKinterface03&funcid=WriteGZJKpermsgRecord&TYPE=2&USRGUID=" + G_APP_USRGUID;_ajax(webUrl,{ ???Height:$(‘#field-range-input‘).val(),//身高 ???Weight:$(‘#inline-range-val‘).text()//体重});
ajax请求封装调用
原文地址:http://www.cnblogs.com/rockyan/p/7598403.html