//Ajax请求封装
var model = new Object();
function Ajax(url,method,id) {
$.ajax({
type: "POST", //localhost:8080
url: url, //请求地址
async:false,//同步
contentType: "application/json; charset=utf-8", //请求类型
data:JSON.stringify(Getcommon(method,id)), //传入组装的参数
dataType: "JSON",//返回参数
success: function (results){
// console.log(results);
model = results;
}
});
return model;
}
function Getcommon(m,id) {
var myDate = new Date();
var time1 = myDate.getTime();
var hash = hex_md5(time1 + authority.secretData);
if(Number(id)){
Nid=Number(id)
}else{
Nid=id;
}
var json = {
"method": m,
"id":Nid,
"timestamp": time1,
"username": authority.usernameData,
"v": config.v,
"sign": hash
};
return json;
var model = new Object();
function Ajax(url,method,id) {
$.ajax({
type: "POST", //localhost:8080
url: url, //请求地址
async:false,//同步
contentType: "application/json; charset=utf-8", //请求类型
data:JSON.stringify(Getcommon(method,id)), //传入组装的参数
dataType: "JSON",//返回参数
success: function (results){
// console.log(results);
model = results;
}
});
return model;
}
function Getcommon(m,id) {
var myDate = new Date();
var time1 = myDate.getTime();
var hash = hex_md5(time1 + authority.secretData);
if(Number(id)){
Nid=Number(id)
}else{
Nid=id;
}
var json = {
"method": m,
"id":Nid,
"timestamp": time1,
"username": authority.usernameData,
"v": config.v,
"sign": hash
};
return json;
}
使用方法,var model = Ajax(url,method,id);