stucked我已经找遍了网站,但我无法找到任何东西,帮助我,所以这里是:jQuery的ajax的load方法装载
我有这个HTML文件,当你点击Get EXTERN它应该把extern.html中的内容放入div命名的内容中,但是当你点击它显示的加载链接时就会陷入困境,就是这样。
的test.html文件
<script type="text/javascript" src="jquery-1.9.1.js"></script>
<script type="text/javascript"><!--
$(document).ready(function() {
// select all the links with class="lnk", when one of them is clicked, get its "href" value
// adds a "loading..." notification, load the content from that URL and
// place only the paragraph which is in the #cnt into the tag with id="content"
$('a.lnk').click(function() {
var url = $(this).attr('href');
$('#content').html('<h4>Loading...</h4>').load(url+ ' #cnt p');
return false;
});
});
--></script>
</head>
<body>
<h1>Web page test.html</h1>
<a href="extern.html" title="Get extern" class="lnk">Get extern</a>
<div id="content">Initial content in test.html</div>
extern.html文件
<h2>Content in extern.html</h2>
<div id="cnt"><p>Some text content in extern.html</p></div>
由于href有一个相对的URL,它不会是SOP。 – Musa 2013-03-17 02:14:07
@Musa确实。我没有注意到我第一次阅读它......但它并不真正影响这两个建议。谢谢! – Steven 2013-03-17 02:40:47