var submitLimitTime = 1000 * 60;//设置表示1分钟的时间
var canSubmit = true;//设置可以提交
var personalExtend={
clear : function() {//把form表单清空
var personalExtendInfoForm = $("#personalExtendInfoForm");
personalExtendInfoForm.find(":text").val("");
personalExtendInfoForm.find(":radio:checked").attr("checked",false);
personalExtendInfoForm.find(":checkbox:checked").attr("checked",false);
//personalExtendInfoForm.find("select").val("-1");
personalExtendInfoForm.find("select").each(function() {
$(this).find("option:first").attr("selected", true);
});
}
update:function()
{
if (!canSubmit) {
alert(demoMessage.submitLimit);
return;
}
$.ajax({
type: "post",
dataType: "json",
url: $.newegg.buildCurrent("Ajax/Customer/AjaxPersonalExtendInfo.aspx"),
timeout: 30000,
data: {
StrExtendInfo:escape(strExtendInfo)
},
beforeSend: function(XMLHttpRequest) {
showProcessing(true);//隐藏提交按钮,显示等待样式
},
success: function(data, textStatus) {
if (data.Type == 0) {
//success
alert(data.Description);
} else if (data.Type == 2) {
//error
alert(data.Description);
}
//alert(data.Data.BlogAddresses);
//alert("Success!");
//window.location.reload();
canSubmit = false;
setTimeout(function() {//settime函数表示过了submitLimitTime时间就执行函数的第一个参数,一般是一个方法
canSubmit = true;//过了一分钟就把canSubmit设置为true,就可以再次提交数据了
}, submitLimitTime);
},
complete: function(XMLHttpRequest, textStatus) {
showProcessing(false);//显示提交按钮,隐藏等待样式
},
error: function() {
alert("error");
}
});
}
}
function getProcessing() {//生成一个等待的样式
var processing = $("#processing");
if (processing.length == 0) {
processing = $('<span id="processing" class="cmnLoadB"><img align="absmiddle" src="' + demoMessage.buttonProcessingImage + '"/>' +
demoMessage.buttonProcessingText + '</span>');
$("#cancelPersonalInfo").after(processing);
}
return processing;
}
function showProcessing(isShow) {//参数是true就隐藏提交按钮,为false就再显示提交按钮
var btnSubmitAndClear = $("#btnSavePersonalInfo,#cancelPersonalInfo");
var btnProcessing = getProcessing();
if (isShow) {
btnSubmitAndClear.hide();
btnProcessing.show();
} else {
btnSubmitAndClear.show();
btnProcessing.hide();
}
}