jquery – How do I get the page via ajax?

Question:

On my site, I need to display a page from another site, that is, I need to get a page from a different domain. For example: my site is www.mysite.com and I need to put text from www.example.com (which is in some div) into it?

Answer:

code on your site:

HTML:

<div id="site"></div>

JS:

var check = $('#site');
$.ajax({    type: "POST",
            url: "http://www.example.com/example.php?xx=value",
            cache: true,
            async: true,
            success:function(response)
                {check.html(response);}
            });

and on the page where the request goes (www.example.com/example.php) there should be a code allowing ajax requests and have an html structure:

PHP:

header('Content-type: text/html');
header('Access-Control-Allow-Origin: *');
Scroll to Top
AllEscort