Php 同一页面中的AJAX加载会导致div重复
我正在对同一个页面执行ajax调用,尽管它重新加载了现有的div,但仍然可以很好地工作。我想知道是否有办法抑制它?详情如下: 我的项目设置 index.php-打开记录控制器Php 同一页面中的AJAX加载会导致div重复,php,jquery,ajax,Php,Jquery,Ajax,我正在对同一个页面执行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'></di
/**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
/*AJAX call to self*/
function getViaAjax(chosenGroup){
$.post('index.php',{group:chosenGroup},
function(data)
{
$("#default").remove();
$('#group-tickets').html(data);
});
}
正如您可能知道的,这会导致页面上的#logo
和#nav
div重复。我知道我可以在不同的文件上发布AJAX文章,我将完全回避这个问题,但我想知道是否有办法做到这一点?试试这个。文档解释:与$.get()不同,.load()方法允许我们指定要插入的远程文档的一部分。
$('#result').load('ajax/test.html #container');
谢谢。它能用,但……它似乎破坏了其他一切。无论如何,我会接受你的回答,因为你给我指出了正确的方向。对不起,如果有其他的答案,我决定重新讨论这个问题。