如何在没有iframe的div中加载外部URL

时间:2017-09-19 12:55:59

标签: javascript jquery angularjs

我想在不使用iframe / embed / object标记的情况下在div中加载外部网址。我已经使用了示例,但它无法正常工作

例如:

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

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

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

根据你的评论,我认为你需要这样的事情:

$('#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);
      }
});

为了更好地了解,我将此问题与this SO帖子

相关联
相关问题