JQuery, ajax, displayed page inside another page (e.g. iframe)

I need to display the page inside the page, for example iframe, but using jquery. Pages are not on the same server.

The main page is an html page inside cms, and the page that should be attached is a media page with lists of images or audio files, which is located on another server. The height will vary on multimedia pages, so I would like to stay away from iframes ... there is a simple call in jquery that will capture a page like an iframe ... or one that degrades to iframe if js is rotated at the level browser?

Thank.

+3
source share
4

, -, AJAX - , .

- , AJAX, - .

mod_proxy Apache ProxyPass. :

ProxyPass     /external/     http://other-domain.com/

/external/index.html URL-, , - http://other-domain.com/index.html.

JavaScript jQuery load() :

$('#your_div').load('external/index.html');

- iframe JavaScript. , :

@Yi Jiang, . HTML- , .

+2

Mozilla Cross-Site-Requests. HTML5. --. - . PHP-, :

<?php
    $external = file_get_contents($_POST['external']);
    echo $external;
?>

$().post("ajax.php", {external: "http://www.example.com/"}, function(data) {
    html = $("div#extract", data).html();
    $("div#insert").html(html);
}, "html");
+2

Ajax . (XSS). , - php, cURL API AJAX Google.

iframe, JavaScript iframe ( , ).

0

Ajax, by definition, runs on only one server due to the same origin policy. What you need to do is load the page from another server into a PHP file (let me call it xxx.php). Then you can load xxx.php into the yyy div with the following code:

$("#yyy").load("xxx.php");
0
source

Source: https://habr.com/ru/post/1759715/


All Articles