Skip to content Skip to sidebar Skip to footer

Disable Href After Clicking (ajax, Js)

I have this code: $('#checkout').click(function() { $.ajax({ type: 'GET', url: 'index.php?route=payment/quatro/confirm', success: function() {

Solution 1:

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; ?>';
        }       
    });
});

Solution 2:

If you return false; at the end of your click event, that should prevent the link from going anywhere.

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

    return false;
});

Post a Comment for "Disable Href After Clicking (ajax, Js)"