Ajax請求綁定手機(jī)號彈窗實(shí)現(xiàn)的代碼片段,以下代碼為項(xiàng)目開發(fā)中的片段,實(shí)現(xiàn)方法思路僅供參考。
// 綁定手機(jī)號彈窗
$(".get-phone").on("click", ".c-btn,.close,.phone-bg", function () {
$(".get-phone").hide();
});
/**
* ajax方法封裝
* @param url
* @param data
* @param type
* @param success
* @param error
* @param beforeSend
* @param async
*/
var ajax = function (url, data, type, success, error, beforeSend, async) {
$.ajax({
url: url,
data: data,
dataType: 'JSON',
type: type,
success: function (res) {
layer.closeAll();
success(res);
},
error: function () {
if (typeof error === 'function') {
error();
} else {
layer.msg('請求錯誤');
}
},
beforeSend: function () {
if (typeof beforeSend === 'function') {
beforeSend();
} else {
var index = layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
}
}
});
};
$('#registerBtn').on('click', function () {
$('#registerModal').removeClass('hide');
});
//隱藏模態(tài)框
$('span[data-bind-bs="hideModal"]').on('click', function () {
var _this = $(this);
_this.parents('div.hkt-win').addClass('hide');
});
$('.show-input > span').click(function () {
$('.show-input').hide();
$('.nav').fadeIn(800);
$('.click-seek').show();
});
// 綁定手機(jī)號彈窗
$(".get-phone").on("click", ".c-btn,.close,.phone-bg", function () {
$(".get-phone").hide();
});
/**
* ajax方法封裝
* @param url
* @param data
* @param type
* @param success
* @param error
* @param beforeSend
* @param async
*/
var ajax = function (url, data, type, success, error, beforeSend, async) {
$.ajax({
url: url,
data: data,
dataType: 'JSON',
type: type,
success: function (res) {
layer.closeAll();
success(res);
},
error: function () {
if (typeof error === 'function') {
error();
} else {
layer.msg('請求錯誤');
}
},
beforeSend: function () {
if (typeof beforeSend === 'function') {
beforeSend();
} else {
var index = layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
}
}
});
};
$('#registerBtn').on('click', function () {
$('#registerModal').removeClass('hide');
});
//隱藏模態(tài)框
$('span[data-bind-bs="hideModal"]').on('click', function () {
var _this = $(this);
_this.parents('div.hkt-win').addClass('hide');
});
$('.show-input > span').click(function () {
$('.show-input').hide();
$('.nav').fadeIn(800);
$('.click-seek').show();
});