点击(ajax,js)后禁用href [英] Disable href after clicking (ajax, js)
问题描述
$('#checkout')。click(function(){
$ .ajax({
type:'GET',
url:'index.php?route = payment / quatro / confirm',
success:function(){
location ='<?php echo $ continue;?>';
}
});
});
什么是禁用这个< a href> 点击它后点击code> link按钮?我试过
$('#checkout')。disabled
函数,但是click函数仍然有效。
在你的点击处理程序的内部,我会添加一个对 unbind
的调用来删除前进的点击处理程序。
$('#checkout')。unbind(click);
所以完整的代码是:
<$ ($#$>'code> $('#checkout')。click(function(){
$('#checkout')。unbind(click);
$ .ajax ({
type:'GET',
url:'index.php?route = payment / quatro / confirm',
success:function(){
location ='< ;?php echo $ continue;?>';
}
});
});
I have this code:
$('#checkout').click(function() {
$.ajax({
type: 'GET',
url: 'index.php?route=payment/quatro/confirm',
success: function() {
location = '<?php echo $continue; ?>';
}
});
});
What is the good way to disable this <a href>
link button after clicking on it? I tried $('#checkout').disabled
function, but the click function is still working.
Inside of your click handler I would add a call to unbind
to remove the click handler going forward
$('#checkout').unbind("click");
So the full code would be:
$('#checkout').click(function() {
$('#checkout').unbind("click");
$.ajax({
type: 'GET',
url: 'index.php?route=payment/quatro/confirm',
success: function() {
location = '<?php echo $continue; ?>';
}
});
});
这篇关于点击(ajax,js)后禁用href的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!