jquery - wait or sleep in javascript -


as can pause code of 1 second before running "post function".

$(document).ready(function() {      $("#button").click(function() {          /*1 second pause before executing post */         $.post(url,{par1=5},function(e){         });     }); }); 

regards.

you can use settimeout:

$("#button").click(function() {     settimeout(function() {         /* 1 second pause before executing post */         $.post(url, { par1 = 5 }, function(e) { } );     }, 1000); }); 

also, assuming want multiple clicks of button send 1 request @ time, can use cleartimeout prevent site being flooded. try this

var timeout; $("#button").click(function() {     cleartimeout(timeout);     timeout = settimeout(function() {         $.post(url, { par1 = 5 }, function(e) { } );     }, 1000); }); 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -