【发布时间】:2016-03-03 06:15:19
【问题描述】:
我有以下 html 标记:
<button class="btn btn-success" id="search"><span class="glyphicon glyphicon-search"></span> Search</button>
<div class="row text-center" style="margin-top: 50px;">
<div class="col-md-12">
<div id="content-area"></div>
</div>
</div>
我想在#content-area 中加载一个page.php。这是我为此使用的 jQuery:
$("#search").click(function(){
$("#content-area").load("page.php");
});
问题是 page.php 没有在 #content-area 中加载,而是作为新页面本身加载。我希望 page.php 加载到 #content-area 中。请帮忙。
【问题讨论】:
-
将负载加载到一个变量中,并使用 html() 方法将变量数据分配给 div。
-
你在做任何类型的搜索吗?为此使用 ajax。
-
您是否给出了 page.php 的完美路径?请检查一次。
-
@DeepKakkar 我使用了这个代码
$("#search").click(function(){ var loadData = load("populateCustomer.php"); $("#content-area").html(loadData); });它仍然加载在一个新页面上,而不是在我的 div 中