Click and pass url to php using ajax?

Asked

Viewed 170 times

0

How do I grab the link when clicking ?

example: I have an iframe with a link that directs to a page, I want to take this link, and pass via ajax pro php.

  • 1

    Can you put the HTML code you have? This iframe is in the same domain?

1 answer

0

            <!DOCTYPE html>
            <html>
            <head>
                <title></title>
                <script  src="https://code.jquery.com/jquery-2.2.4.min.js"
                          integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
                          crossorigin="anonymous"></script>
            </head>
            <body>
                 <iframe id="xframe" src="https://www.w3schools.com"></iframe> 
                 <script>
                    $(document).ready(function() 
                        {
                            var aqui = $("#xframe").attr("src");//Pegando o link do Iframe
                            /*RELALIZANDO O AJAX COM O METODO POST*/

                            $.post("/meulink.com.br", {"endereco": aqui}, function(data)
                            {
                                alert(data);

                            });

                        });


                 </script>

            </body>
            </html>
  • It would be very nice if you would post html here to give us a sense of what you are looking for, but this example I think will help you.

Browser other questions tagged

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