javascript - How to load another domain content inside a div? -


i have <div id="content">. want load content http://vietduc24h.com div:

<html> <head> <script type="text/javascript">     $(document).ready(function()     {         $("#content").attr("src","http://vietduc24h.com");     }) </script> </head> <body>     <div id="content"></div> </body> </html 

i don't want use iframe. how can this?

you need think cors in aspect. code need have is:

<script type="text/javascript">     $(document).ready(function()     {         $("#content").load("http://vietduc24h.com");     }) </script> 

when domain not inside vietduc24h.com, might security exception. in order avoid that, can host local proxy here. in php, way (url.php):

<?php     $url = file_get_contents(urlencode($_get["url"]));     echo $url; ?> 

and in script, need modify way:

<script type="text/javascript">     $(document).ready(function()     {         $("#content").load("proxy.php?url=http://vietduc24h.com");     }) </script> 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -