$.najax = function (options) {
var opts = $.extend({
alerterror: false, alertbierror: false, cache: false, dataType: "json"
}, options);
opts.success = function (data) {
$.loading(false);
if (options.success) {
options.success(data);
}
}
opts.error = function () {
$.loading(false);
if (options.error) {
options.error();
}
}
opts.beforeSend = function () {
$.loading(true);
};
opts.complete = function () {
$.loading(false);
if (options.complete) {
options.complete();
}
};
$.ajax(opts);
}
//loading效果
$.loading = function (bool) {
if (bool) {
document.getElementById("load").style.display = "";//显示等待效果
document.getElementById("load").style.cursor = "wait";//鼠标开始等待
} else {
document.getElementById("load").style.display = "none";//结束等待效果
document.getElementById("load").style.cursor = "default";//鼠标停止等待
}
}
评论区