jQuery的/阿贾克斯从AJAX加载的页面删除DIV [英] Jquery/Ajax remove div from page loaded by ajax

查看:105
本文介绍了jQuery的/阿贾克斯从AJAX加载的页面删除DIV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过jQuery / AJAX调用PHP页面的脚本。结果是这样的:

I have a script that calls a php page via jquery/ajax. The results would look like this:

<table class="table" cellspacing="0" width="100%">
  <thead>
    <tr>
      <th scope="col">Title1</th>
      <th scope="col">Title2</th>
      <th scope="col">Title3</th>
    </tr>
  </thead>
  <tbody><?php echo $wait_list; ?></tbody>
</table>
<div>
  <div id="statcount">Rows: <?php echo $row_count; ?></div>
</div>

当这是通过所谓的jQuery的/ AJAX调用它显示的表信息,并在年底的分区信息。不过,我不希望底部的div显示,其实我是想从数据中删除,我只是在那里,所以我可以抓住计数并把它放在不同的分区从脚本中调用这个文件,所以我没有做2单独的jQuery / AJAX调用。因此,当jQuery的/ AJAX调用时运行此成功:

When this is called via the jquery/ajax call it displays the table information and at the end the div information. However I dont want the bottom div to show, I actually want it removed from the data, I just have it there so I can grab the count and put it in a different div from the script calling this file so I dont have to make 2 seperate jquery/ajax calls. So when the jquery/ajax call is made it runs this on success:

  function updateList(data){
      $('#rowcount').html($('#statcount',data).html());
      $('#statcount',data).remove();
      $("#waitlist").html(data);
  }

正如你所看到的即时通讯使用div来填充网页上的一个单独的区域。但是一旦做到这一点,我不想从PHP页面的div来显示在#waitlist。我试过remove()函数正如你看到的上面,但是,这并不工作。有什么建议?

As you can see Im using that div to populate a seperate area on the page. But once that is done I dont want the div from the php page to show up in #waitlist. I tried the remove() function as you see above but that doesnt work. Any suggestions?

推荐答案

我觉得你逝去的数据作为jQuery选择范围参数,因此你没有得到任何比赛。 试试这个:

I think you are passing data as the scope parameter for jQuery selector and hence you are not getting any matches. Try this:

function updateList(data)
{       
    var lData = $("<div>" + data + "</div>");
    $('#rowcount').html($('#statcount',lData).html());       
    $('#statcount',lData).remove();       
    $("#waitlist").html(data);   
}

这篇关于jQuery的/阿贾克斯从AJAX加载的页面删除DIV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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