标签:style io os java ar for 文件 sp cti
base.js
//ajax请求 var ajaxRequest = function () { }; ajaxRequest.prototype = { //初始化设置 url : '', dataType : 'json', data:'', //初始化ajax参数 setUp : function(){ $.ajaxSetup({ url : this.url, data : this.data, dataType : this.dataType, type : 'post', contentType : 'application/x-www-form-urlencoded; charset=UTF-8' }); }, //执行请求 requst: function () { var req = $.ajax({ }); return req ; } };
具体调用方式:
var params = { name: name, nickname: nickname, password: password, email: email, status:status, level:level };//创建json格式参数 var url = "xxxxx.xxxxx.action"; submit(url,params); //表单提交 function submit(url,params){ var ajaxReq = new ajaxRequest(); ajaxReq.url = url; ajaxReq.dataType = "json"; ajaxReq.data = params; ajaxReq.setUp();//初始化ajax var requst = ajaxReq.requst(); requst.done(function(result) {//回调 // console.log(typeof result); // console.log(result ); }); requst.error(function(data){ alert("网络异常!"); }); }
标签:style io os java ar for 文件 sp cti
原文地址:http://blog.csdn.net/lyc66666666666/article/details/39432461