
JS Tip
ezjQuery » JS Tip » JS tip »» Prev | Next
ezjQuery » JS Tip » Plugins
Add Comment
Subject: How to avoid user multiple submissions
Author: EZjquery
Tag: Ajax
Post Time: 2008/05/15 21:19:47
Email Address: jquerylearning@gmail.com
How to avoid user multiple submissions or click
suppose you do a reservation for a flight and the online reservation service system didn't include the
avoid multiple submit and the processing time for flight reservation system take more than your
expect. so you need do something to avoid user multiple submissions
javascript Way
Code
<script language=javascript >
var is_form_submited=0;
function enableJS()
{
document.testing.jsEnabled.value="yes";
return true;
}
function processInput()
{
if (is_form_submited==1)
{
alert("Your request has been submitted. please wait..");
return false;
}
enableJS();
is_form_submited=1;
return true;
}
</script>
jQuery Way
(only add async: false, to you code)
example your code just like following
Code
$.ajax({
type: "POST",
url: "/cgi-bin/webapp.rb",
//..........Do some function
change it like this
Code
$.ajax({
type: "POST",
url: "/cgi-bin/webapp.rb",
async: false,
// .....Do some function
ezjQuery » JS Tip » JS tip »» Prev | Next
ezjQuery » JS Tip » Plugins
Add Comment»Add comment
Top