user1048676
user1048676

Reputation: 10066

jQuery prevent default link click in IE8

All, I've got the following jQuery code:

jQuery(".select_it").click(function(e){
    e.preventDefault();
    song_id = jQuery(this).attr('href');
    music_choice = jQuery("#song_type").val();
    jQuery.post(site_url + "save_song_choice.php", { song_id: song_id, music_choice: music_choice },
        function(response) {
            alert(response);
            var url = site_url + "okyne-form";
            window.location.replace(url);
        });
        return false;
    }
);

When I click on the link, it doesn't perform the jQuery but instead takes the behavior that the link was clicked. How can I prevent this from happening?

Thanks!

Upvotes: 0

Views: 1383

Answers (1)

eos87
eos87

Reputation: 9353

try putting the return false; out of the jQuery.post like this:

jQuery(".select_it").click(function(e){
    jQuery.post(url, function(){
        //code here   
    });
    return false;
});

Upvotes: 2

Related Questions