[英]AJAX load in same page causes divs to repeat
我正在對同一頁面執行ajax調用,但是它會重新加載現有的div。 我想知道是否有辦法壓制它? 這里有更多細節:
index.php - 打開記錄控制器
/**app logic**/
view('open',$data); //require '../views/layout.php';
layout.php中
/*all the js scripts and stylesheets loaded here*/
<div id='logo'></div>
<div id='nav'></div>
include($path); //loads the open.view.php file
open.view.php
/*AJAX call to self*/
function getViaAjax(chosenGroup){
$.post('index.php',{group:chosenGroup},
function(data)
{
$("#default").remove();
$('#group-tickets').html(data);
});
}
正如您可能知道的那樣,這會導致#logo
和#nav
div在頁面上重復。 我知道我可以將AJAX帖子發送到另一個文件,我會徹底解決這個問題,但我想知道是否有辦法做到這一點?
試試這個鏈接 。 文檔說明: The .load() method, unlike $.get(), allows us to specify a portion of the remote document to be inserted.
$('#result').load('ajax/test.html #container');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.