在easyui中,在创建新用户时,如何在将请求发送到php以在数据库中插入相同内容时禁用对保存按钮的多次单击
function saveUser() {
$('#fm').form('submit', {
url: url,
onSubmit: function() {
return $(this).form('validate');
},
success: function(result) {
if (result === 'exists') {
$.messager.alert('Alert', 'Name already exists!\nPlease enter different Name', 'info');
$('#fm').form('clear');
} else {
$('#dlg').dialog('close'); // close the dialog
$('#dg').datagrid('reload'); // reload the user data
}
}
});
}在没有收到来自php文件的响应之前,我不希望发送另一个请求。
发布于 2017-07-24 14:33:19
您可以在单击提交按钮后立即将其禁用,
请检查以下代码,希望能对您有所帮助:
function saveUser() {
$('#fm').form('submit', {
url: url,
onSubmit: function() {
//Code to Disable the submit button comes here.
$("#SubmitButton").attr('disabled',true);//Assuming SubmitButton is the ID of the button.
return $(this).form('validate');
},
success: function(result) {
if (result === 'exists') {
$.messager.alert('Alert', 'Name already exists!\nPlease enter different Name', 'info');
$('#fm').form('clear');
} else {
//If you want to allow the user to click on the Submit button now you can enable here like this :
$("#SubmitButton").attr('disabled',false);
$('#dlg').dialog('close'); // close the dialog
$('#dg').datagrid('reload'); // reload the user data
}
}
});
}https://stackoverflow.com/questions/45273611
复制相似问题