Call link using Ajax

Asked

Viewed 369 times

0

Hello,

I have this code here: Código já feito

If I click on the number is called the href but opens the link on the same page because it has the target="_self".

What I wanted was to click the number to call the link but without re-loading the page and/ or open the link in a new tab. The ideal would be to make an Ajax call, but I don’t know how to do it. Someone can help me?

I’ve tried the following code:

$(document).ready(function(){
  $("button").click(function(){
    jQuery.ajax({
      type: 'POST',
      url: 'https://www.youtube.com/',
      async: true,
      success :  function(data){
        console.log("sucesso");
      }
    });
    return false;
  });
});

The code runs but does not execute the url, I am doing something wrong?

  • 1

    Have you tried looking for "called ajax"? you will find several examples, here on the site itself have good examples with questions and answers like this: https://answall.com/questions/10664/como-enviarvari%C3%A1veis-string-as-par%C3%A2metro-to-call-ajax

  • It would then just be change the url in case link by my link instead of "meu_script.php"?

  • I updated my question showing the code I’ve tried to use.

  • basically this, and the next step would be to check what comes in the object "data", which should return something, but the call ajax itself is that same that put in the question, just do not forget to put the parameters in the url, at the beginning of the question, the link sends a parameter by querystring in the url, the "phone=455751"

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.