67 lines
1.6 KiB
JavaScript
67 lines
1.6 KiB
JavaScript
var myJs = {};
|
||
myJs.get = function (url, data, success, error) {
|
||
$.ajax({
|
||
url: url,
|
||
type: "get",
|
||
data: data,
|
||
success: function (d) {
|
||
success(d);
|
||
},
|
||
error: function (d) {
|
||
if (!error) {
|
||
error = function (s, i, m) {
|
||
myJs.msg(m);
|
||
};
|
||
}
|
||
error(d.status, d.responseJSON.Id, d.responseJSON.Message)
|
||
},
|
||
});
|
||
}
|
||
myJs.post = function (url, data, success, error) {
|
||
$.ajax({
|
||
url: url,
|
||
type: "post",
|
||
data: data,
|
||
success: function (d) {
|
||
success(d);
|
||
},
|
||
error: function (d) {
|
||
if (!error) {
|
||
error = function (s, i, m) {
|
||
myJs.msg(m);
|
||
};
|
||
}
|
||
error(d.status, d.responseJSON.Id, d.responseJSON.Message)
|
||
},
|
||
});
|
||
}
|
||
myJs.msg = function (msg) {
|
||
alert(msg);
|
||
}
|
||
//保存用户凭据的键,在_layout视图设置
|
||
myJs.userKey = "";
|
||
//获取登录的用户票据
|
||
myJs.getTicket = function () {
|
||
return $.cookie(myJs.userKey);
|
||
}
|
||
//移除用户登录票据
|
||
myJs.removeTicket = function () {
|
||
$.removeCookie(myJs.userKey);
|
||
}
|
||
|
||
myJs.url = {
|
||
app: {
|
||
AddNewApp: "api/app/AddNewApp",
|
||
RemoveApp: "api/app/RemoveApp",
|
||
GetApps: "api/app/GetApps",
|
||
GetAppList: "api/app/GetAppList",
|
||
},
|
||
user: {
|
||
GetUsers: "/api/User/GetUsers",
|
||
AddNewUser: "/api/User/AddNewUser",
|
||
RemoveUser: "/api/User/RemoveUser",
|
||
},
|
||
};
|
||
|
||
|
||
var mydata = {} |