I am trying to load an external .htm file to a div on my main page, and I have used the following code:
<a href="#file.htm" onclick="$('#content').load('file.htm')">Link</a>
It works in firefox, but not in chrome and IE. Can anyone help me?
I am trying to load an external .htm file to a div on my main page, and I have used the following code:
<a href="#file.htm" onclick="$('#content').load('file.htm')">Link</a>
It works in firefox, but not in chrome and IE. Can anyone help me?
为什么不
html
<a href="file.htm" class="ajax">Link</a>
并添加一个脚本
<script type="text/javascript">
$(function(){
$('.ajax').click(function(e){
e.preventDefault();
$('#content').load( this.href );
});
});
</script>
这样,您可以ajax
为该区域内加载的所有链接设置一个类,#content
并处理所有这些链接。
可能是它不起作用的原因是您单击得太快并且尚未加载 jquery 吗?