1

I want to load external url in a div without using iframe/embed/object tag. I already used examples but it is not working

For example:

$("#testDiv").load("//localhost:8000/cities/Mountain%20View/521/bottle-service/new");

or

$("#testDiv").load("//www.xyz.com");

Could anyone please help me fix this issue?

Manoj K
  • 21
  • 2
  • 7
  • Define "it's not working" – Cruiser Sep 19 '17 at 12:58
  • What do you want to load? If you want to render an external website you have to use an iframe. If you want to do an AJAX request it doesn't really matter. So what is it? – getjackx Sep 19 '17 at 13:00
  • i want to load the external url in my page. it may be the url of my own website or external website page(url)...but within div tag only.. – Manoj K Sep 19 '17 at 13:07

1 Answers1

0

Based on your comment I think you need something like this:

$('#mydiv').load('http://localhost:8000/cities/Mountain%20View/521/bottle-service/new #testDiv', function(response, status, xhr) {
    if (status == "error") {
        var msg = "Sorry but there was an error: ";
        alert(msg + xhr.status + " " + xhr.statusText);
      }
});

For better insight I'm linking this question with this SO post

Mr. Pyramid
  • 3,855
  • 5
  • 32
  • 56
  • i need to implement only in div tag. I already done this but my client is not satisfy with iframe/object tag. I need to know how to implement external url only in div tag. – Manoj K Sep 19 '17 at 14:12
  • ok I have updated my answer I think this will surely to the trick for you :) – Mr. Pyramid Sep 19 '17 at 17:19
  • you can accept my answer > https://stackoverflow.com/help/someone-answers – Mr. Pyramid Oct 12 '17 at 14:02