点击(ajax,js)后禁用href [英] Disable href after clicking (ajax, js)

查看:161
本文介绍了点击(ajax,js)后禁用href的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $('#checkout')。click(function(){
$ .ajax({
type:'GET',
url:'index.php?route = payment / quatro / confirm',
success:function(){
location ='<?php echo $ continue;?>';
}
});
});

什么是禁用这个< a href> 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆