1

I want to load an external file into my file. the external file present another server and my file present in another server.

If i use this $("#content").load("content.html"); that is works fine the the both file in same server but my files are having different server

Example:

my file present in my local server

inside index.html there is div having div id "content"

and menu.html file present in http://phpraddyx.com/

$(document).ready(function(){
        $("#content").load("menu.html");

    });
psanjib
  • 1,255
  • 2
  • 15
  • 24
  • try `$("#content").load("http://phpraddyx.com/menu.html");` – Sridhar R Nov 20 '13 at 07:08
  • 1
    `the external file present another server and my file present in another server` can't be done. `Cross origin issue` – Jai Nov 20 '13 at 07:10
  • also i have tried this way `$("#content").load("http://phpraddyx.com/menu.html");` not working – psanjib Nov 20 '13 at 07:12
  • Without additional server-side technologies such as PHP, ASP, Ruby, Node.js, or Java, you cannot load most content cross-domain due to security concerns. There are a few options, such as iFrames in HTML, but these have their limits too. – Chris Baker Nov 20 '13 at 07:14
  • [Possible Duplicate](http://stackoverflow.com/questions/12032664/load-a-html-page-within-another-html-page) – Prateek Nov 20 '13 at 07:19
  • if you are going to use php, try Simple HTML DOM Parser: http://simplehtmldom.sourceforge.net, and convert the result as string so you can use it in html. – user2002495 Nov 20 '13 at 07:26

3 Answers3

-1

Load a local .php file into your container which itself is getting and returning the content if the external source (this course assumes that PHP is installed)

Joachim Ruisz
  • 121
  • 1
  • 1
  • 7
-1

I think you can create a proxy page on you local server, e.g.

proxy.cgi?url='.....'

And use this server cgi page to fetch the url and return the content.

Andrew
  • 5,290
  • 1
  • 19
  • 22
-1

If this is only for designing, use iframe instead. (e.g. loading head menu links, etc.)
<iframe src="http://phpraddyx.com/" width="#" height="#">

Or since the code will work in the same server, save the Java file on that server and load it on HTML file stored in other server:
<script src="http://phpraddyx.com/menu.js"></script>

FrozenFire
  • 671
  • 14
  • 28