我正在尝试使用jquery .load将内容从另一个html文件加载到我现有的html文件中。
但不幸的是,它没有加载内容。
请给我提个合适的解决方案。
下面是我用来从外部html文件加载内容的现有HTML和jquery
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Review</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
<ul class="reviews" id="revw">
</ul>
</div>
<script>
function check(){
$( "#revw" ).load( "review_list.html #test" );
}
</script>
</body>
</html>我们需要从其中加载内容的页面
<html>
<head></head>
<body>
<div id='test'>
Load this content to the id="revw" div.
</div>
</body>
</html>发布于 2013-09-20 13:41:45
您不会在任何地方调用函数check()。
试试这个:
...
<script>
function check() {
$( "#revw" ).load('review_list.html #target');
}
$(document).ready(function() {
check(); // call the function
});
</script>
...发布于 2013-09-20 13:57:05
使用$.get尝试一下。
$(document).ready(function() {
$.get('review_list.html')
.success(function(data) {
$('#revw').html(data);
});
});您的HTML页面
<div id='test'>
Load this content to the id="revw" div.
</div>发布于 2013-09-20 13:46:16
请参阅此链接:
Load one page in to another using Jquery
它对你的问题有详细的解释
Delayed loading of a html page using jquery
这两个都会解决这个问题。
https://stackoverflow.com/questions/18909567
复制相似问题