尝试从一个站点加载 div 并在另一个站点上使用 jQuery 显示它,但没有任何显示

Trying to load a div from one site and display it on another with jQuery, nothing showing up

正如标题所说,我需要在另一个网站上显示来自一个网站的 div。我在下面创建了一个小测试,afaik 应该使用 jQuery 的 .load 工作,但是当我打开它时没有任何显示。如有任何帮助,我们将不胜感激!

<html>
<head>
<script type="text/javascript" src="javascript/jquery-1.3.2.min.js">
</head>
<body>
<script>
$('#transaction-section'.load('ajax/http://warburgrealty.com/agent/AGENT-69db6245d34d32e69208161ebcc412fe/samantha-frith #past-transactions-section');
</script>
<div id="transaction-section"></div>
</body>
</html>

你有几件事正在进行。

首先,语法不太正确。我还会在 div 定义之后移动 JavaScript。

<div id="transaction-section"></div>
<script>
$('#transaction-section').load('http://warburgrealty.com/agent/AGENT-69db6245d34d32e69208161ebcc412fe/samantha-frith');
</script>

其次,除非您 运行 在 warburgrealty.com 上使用此代码,否则您将 运行 进入 cross-origin 请求错误。

您可以在此处阅读有关 cross-origin 资源共享的更多信息:https://enable-cors.org/