Ajax请求绑定手机号弹窗实现的代码片段
时间:2018-03-27 来源:风信官网 点击:
734次
Ajax请求绑定手机号弹窗实现的代码片段,以下代码为项目开发中的片段,实现方法思路仅供参考。
// 绑定手机号弹窗
$(".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');
});
//隐藏模态框
$('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();
});