jQuery .load()不起作用 [英] jQuery .load() not working

查看:684
本文介绍了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>

需要考虑的事项:


  • 图书馆加载正常。

  • 如果我输入任何其他代码,它可以工作(如测试警报(1);)。

  • 控制台不报告任何错误。

  • div保持空白;其实,它甚至没有显示。它在那里,但是。

  • The library loads just fine.
  • If I enter any other code, it works (like testing alert(1);).
  • The console doesn't report any errors.
  • The div stays blank; in fact, it doesn't even show. It is there, though.

我做错了什么?

推荐答案

你的代码应该是这样的

<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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆