jQuery .load() 不工作 [英] jQuery .load() not working
本文介绍了jQuery .load() 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的网站上,我尝试使用 jQuery 提取论坛(托管在同一域中)中的帖子内容,并将其显示在主页的 div 中.
On my website, I'm trying to pull the content of a post in my forum (hosted on the same domain) and display it in a div on the homepage, using jQuery.
这是标题的代码:
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
<script type="text/javascript">
jQuery("#contain").load("http://examplepage.com/forum/showthread.php?tid=NN #pid_NN");
</script>
然后是我想显示帖子的 div:
Then, there's the div I'd like to display the post:
<div id="contain"></div>
需要考虑的事项:
- 库加载得很好.
- 如果我输入任何其他代码,它就会起作用(例如测试 alert(1);).
- 控制台没有报告任何错误.
- div 保持空白;事实上,它甚至没有显示.不过,它就在那里.
我做错了什么?
推荐答案
你的代码应该是这样的
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
js 代码
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#contain").load("http://examplepage.com/forum/showthread.php?tid=NN #pid_NN");
});
</script>
这篇关于jQuery .load() 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文