凡页面中输入的信息,一般都是需要和后台服务器相关联的,因为输入的信息需要保存,浏览时,信息需要从服务器上取得。
confirm按钮的验证条件什么的,就不再讨论了,下面直接附上confirm中,一切信息输入格式正确的else内的代码。
保存信息:
$.ajax({ url:config.baseServerUrl +'/account/customer/houseInfo/save', type:'post', data:{ //向服务器(接口)提交的参数 houseStatus:$conditionSlt.val(), housePay:$("#housePay").val(), customerId:customerId, pro:$provinceSlt.text(), city:$citySlt.text(), county:$areaSlt.text(), addrDetial:$("#detail").val() }, success:function(data){ //返回的提示信息 console.log(data); if(data.success){ alert("保存成功!"); window.location.href="http://192.168.220.55/page/AmountAscension/basicInfo/basicInfo.html"; }else{ return false; } } })展示信息:
var customerId=sessionStorage.customerId; //用户ID随时用随时取 $(function(){ $.ajax({ url:config.baseServerUrl +'/ account/customer/info', type:'get', data:{customerId:customerId}, //需提交的参数 success:function(data){ console.log(data); //打印数据 if(data.success){ //工作信息 var work=data.attr.workInfo; //将数据取得并赋值,用于展示 var workHtml='<div class="li_span_right">' + '<p><span id="work_job">'+ work.job +'</span><span id="work_organization">'+ work.organization +'</span></p>' + '<p><span id="work_jobPhone">'+ work.areaNo +'</span><span id="work_jobPhone">'+ work.phoneNo +'</span><span id="work_jobPhone">'+ work.branchNo +'</span>' + '<p><span id="work_jobAdress">'+ work.pro +'</span><span id="work_jobAdress">'+ work.city +'</span><span id="work_jobAdress">'+ work.county +'</span></p>' + '<span id="work_workDepart">'+ work.workDepartment +'</span><span id="work_position">'+ work.position +'</span></p>' + '<p><span id="work_industry">'+ work.industry +'</span><span id="work_enter">'+ work.enterpriseScale +'</span><span id="work_classes">'+ work.classes +'</span></p></div>'; $("#workInfo").append(workHtml); //住房信息 var house=data.attr.houseInfo; var houseHtml='<div class="li_span_right">' + '<p><span id="house_condition">'+ house.houseStatus +'</span><span id="house_pay">'+ house.housePay +'</span></p>' + '<p><span id="house_province">'+ house.pro +'</span><span id="house_city">'+ house.city +'</span>' + '<span id="house_area">'+ house.county +'</span><span id="house_detial">'+ house.addrDetial +'</span></p></div>'; $("#houseInfo").append(houseHtml); } } }) })
原文地址:http://blog.csdn.net/comeonstone/article/details/43308323