douxian1895 2017-08-30 10:34
浏览 23
已采纳

如何处理加载事件并在jquery中追加

Hi I have a problem while using set interval function with .load events and append please explain what I did mistake in my code please give a solution

HTML

<div id="user2<?php echo $d['qid'] ;?>">

Comments Loads Here

Jquery code

 setInterval(function(){

  $("#user2").load( "test2.php,#user2");

   },1000); 

qid means Query id I have multiple(qid) queries in my site How to add append please give a solution I am new in jquery Thanks in advance

  • 写回答

2条回答 默认 最新

  • douxia1988 2017-08-30 12:07
    关注

    Id of div is dynamic, as "qid" is appended to it.

    <div id="user2<?php echo $d['qid'] ;?>">

    In above code, if "$d['qid']" is 101, then generated html will be as given below.

    <div id="user2101">

    Hence, your javascript must include dynamic id using "" syntax. Also, you should be using space instead of comma in load event (http://api.jquery.com/load/#loading-page-fragments). You should be passing "qid" to "test2.php" page as query string to get comments related to "qid".

    setInterval(function(){
    
      $("#user2<?php echo $d['qid'] ;?>").load( "test2.php #user2");
    
       },1000);

    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器