首页 > 代码库 > ajax请求

ajax请求

var host = location.hostname;
var bas_url = "http://192.168.2.242:6063/";
var bas_url = "http://" + host + ":6063/";
var svr_url = bas_url + "RSTinyWebService.asmx/";

var svr_auth = bas_url + "GjtWebService.asmx/";

function getInfo(url, para, call, error) {
$.ajax({
type: "post",
contentType: "application/json",
data: para,
url: url,
dataType: ‘json‘,
success: function (result) {
if (call) {
call(result);
}
},
error: function (err) {
if (error) {
error(err);
}
}
});
}

 

//登录
function login() {
var name = $("#form-username").val();
var pwd = $("#form-password").val();
if (!name) {
dialog.alert("用户名不能为空!");
}
if (!pwd) {
dialog.alert("密码不能为空!");
}
getInfo(svr_auth + "Login", JSON.stringify({ name: name, pwd: pwd }), function (res) {
if (res.d.IsOK) {
BD.loginUser = res.d.Info;
if(BD.loginUser.IsActive==false){
dialog.alert("该用户已禁止使用本系统!");
return;
}
else{
BD.rights = JSON.parse(res.d.Info2);
LoginUserName = BD.loginUser.Name;
getProduct();
}

}
else{
dialog.alert("登录失败,请检查用户名或密码!");
}
});
}

ajax请求