HTML Anchor tag redirect link after ajax request

后端 未结 3 1048
独厮守ぢ
独厮守ぢ 2020-12-03 19:23

I\'m trying to write a method to catch user clicks on a site menu, but I want the process to be silent for the user, mainly, that when a user hovers over an anchor tag, it w

3条回答
  •  长情又很酷
    2020-12-03 20:22

    Try This

    
    

    Then this in jquery:

    $(".selectAnchor, .menuAnchor").click(function(event){
        event.preventDefault();
        console.log(event.target.nodeName);
        //event.preventDefault();
    
        $.ajax({
          type: 'POST',
          url: 'http://localsite/menuRedirect.php',
          data: {id:0, module:'Module',source:'Source'},
          complete: function(data){
            console.log("DONE");
            window.location = "http://www.google.com"
          }
        });
    });
    

提交回复
热议问题