Jquery 从另一个网页获取元素的内部html?

Jquery 从另一个网页获取元素的内部html?,jquery,html,innerhtml,Jquery,Html,Innerhtml,如何使用JavaScript从另一个网页获取元素的innerHTML 例如: <script> $.get(url, function(response) { var $response = $(response); // Code not working from this line alert($response.find('.result').html()); // get innhtml of element by class name from re

如何使用JavaScript从另一个网页获取元素的
innerHTML

例如:

<script>
  $.get(url, function(response) {
     var $response = $(response); // Code not working from this line
     alert($response.find('.result').html()); // get innhtml of element by class name from response
  });
</script>

$.get(url、函数(响应){
var$response=$(response);//代码不能从此行开始工作
警报($response.find('.result').html());//从响应中按类名获取元素的innhtml
});
JQuery的
.load()
将准确地执行以下操作:

$('#result').load('ajax/test.html #container');

此处的更多信息:

这取决于您的响应是否包含html,而不是这是否有效

    <script>
      $.get(url, function(response) {
         $('yourelement_selector',response).html();
      }
    </script>

$.get(url、函数(响应){
$('yourelement_selector',response.html();
}

您可以使用下面的post方法示例从其他站点获取数据,并将该数据放入站点div/span等数据容器中

$.post("http://www.otherweburl.com",function (data) {
        document.getElementById("htmlContainerDivOrSpanETC").innerHTML=data;
});
问题1:
必须是

问题2:您尚未完成对
获取
,添加
)的函数调用到脚本的末尾

除此之外,如果提供适当的输入,脚本


然而,jQuery(和/或它调用的底层浏览器方法)的奇特之处意味着,如果您试图匹配的元素是您正在加载的文档中body元素的子元素,那么它们将是jQuery对象中的顶级元素,因此您无法通过
find
找到它们(因为它们不是后代)。如果要匹配这样的元素,请改用。

问题是如何从另一个页面获取元素,而不是整个页面的HTML。它没有说明如何使用post,也没有说明网站是外部的。提醒你的回复看看你是什么getting@JAslu-该网站没有授予我网站上的JavaScript读取其内容的权限。