0

I want to add another wesbite on my webpage.

<script>
$("#new-nav").load("https://google.com");
</script>

This is exactly what I would like to achieve. I would like to load another page using an url on my current page

 <script>
    $("#new-nav").load("http://localhost:8080/xyz/page");
    </script>

but it's not working..

<div id="new-nav"></div>

How do I achieve this? I would like a jQuery solution.

T. Junghans
  • 11,385
  • 7
  • 52
  • 75
supersaiyan
  • 1,670
  • 5
  • 16
  • 36
  • possible duplicate of [Ways to circumvent the same-origin policy](http://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy) – Quentin May 02 '13 at 08:28
  • Check in `browser` that this url `http://localhost:8080/xyz/page` is running individually – Rohan Kumar May 02 '13 at 08:28

3 Answers3

1

on load add another website

your secure browser won't accept in that way. you are doing a wrong thing and violating the origin policy

use something like

$('#new-nav').html('<iframe src="http://localhost:8080/xyz/page"></iframe>');

If it is your same site

check localhost:8080/xyz/page is working or not and wrap your code in document.ready function.other wise your script wont fire.

Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
0

It looks like the issue may be due to the .load request being an AJAX request. If it is in a different domain, it will not load correctly.

More Info on jQuery .load

Turnerj
  • 4,258
  • 5
  • 35
  • 52
0

You can try something like this:

<iframe id='otherSite'></iframe>

<script type='text/javascript'>
    $(document).ready(function()
    {
        $('#otherSite').load('http://localhost:8080/xyz/page');
    });
</script>
Þaw
  • 2,047
  • 4
  • 22
  • 39