如何使用 jQuery 在本地 div 元素中显示外部 url 内容?
我试过的代码无法加载,即使我使用 php 来处理跨域请求也是如此。
抓取.php
<?php echo file_get_contents($_GET['url']); ?>
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="http://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
$(function(){
var contentURI= 'en.wikipedia.org/wiki/Film #mw-content-text';
$('#response').load('grab.php?url='+ contentURI);
});
</script>
</head>
<body>
<div id="response"></div>
</body>
</html>
最佳答案
我建议你使用 iframe 方法。
关于javascript - 使用 jQuery load() 显示来自外部 URL 的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47986762/