[Solved] Save advert click to database using PHP, then open link


You will want to do something like

$(function() { 
  $(".advertLink").on("click",function(e) { 
    e.preventDefault(); // stop the link unless it has a target _blank or similar
    var href = this.href;
    var id=this.id; // or $(this).data("advertid") if you have data-advertid="advert1" on the link
    $.post("./wp-content/plugins/facilitaire-advert-widget/save-advert-click.php",
       { "action":"call_this", "advert_ID":id },
       function() {
         location=href; // or window.open
       }
     );
  });
});

using

<a href="https://stackoverflow.com/questions/36572700/url_to_load" id="advert1" class="advertLink">Link of Advert</a>

6

solved Save advert click to database using PHP, then open link