i'm using this code to load a php page inside a html page using javascipt , but it doesn't work. the code is below :
<html>
....
<div id="home" style="background: #000;background-image: none;height:100%;"></div>
<script>
$('#home').load('http://www.website.com/file/index.php').trigger("create");
</script>
</html>
the php file exists and works fine but it doesn't show up in the actual page . If you have modification i can make i'll be thankful
If you remote website is not in same server you can't do it, for same-origin policy security restrictions, as specified in the load() documentation.
But, you will have a proxy script like:
proxyScript.php
<?php echo file_get_contents("http://www.website.com/file/index.php"); ?>
And, now, you can: $('#home').load('proxyScripts.php').trigger("create");
Or you will configure your remote server to accept remote request, read: How to use Cross domain Ajax request
I think it has something to do with javascript happening AFTER php happens.
Why not switch it with
include(' http://www.website.com/file/index.php ');
if your hiding that div you could just use javascript to show / hide the div based on what ever happens. Dont try to lead the php file when its hovered or clicked or w/e. Load it first and just display it with js.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.