[英]Loading a page then loading just the div
I am using some JQuery to load a div from another page to the current page, the problem I am having is that the content is the div does not exist until that page has loaded. 我正在使用一些JQuery将另一个页面的div加载到当前页面,我遇到的问题是,直到该页面加载,内容才是div。
<div id="placeholder"></div>
What I am trying to do is load the page first (So the content goes into the div) and then I want to load the div in the current page. 我想做的是首先加载页面(因此内容进入div),然后我想在当前页面中加载div。
Currently I have something which looks like this: 目前,我有这样的东西:
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<div class="panel-body">
<div id="bar-chart-db" class="height-sm"></div>
</div>
<script>
$( "#bar-chart-db" ).load( "../index.aspx #placeholder" );
</script>
Is what I want to do possible and if it is, any suggestions? 我是否想做些什么,如果可以的话,有什么建议吗?
you have to wrap the jquery in a document ready function: 您必须将jquery包装到文档就绪函数中:
$(function(){
$( "#bar-chart-db" ).load( "../index.aspx #placeholder" );
});
Here is something you might want to read: Document Ready Function 您可能需要阅读以下内容: 文档就绪功能
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.