weixin_33682719 2014-03-28 04:42
浏览 25

Javascript和Ajax响应

I have a javascript files that is suppose to interact with the response of my ajax request but apparently the javascript can't read the response from the ajax request.

What I'm asking is, how can I make my jquery plugin read the class in the response of my ajax request?

This is how my script looks without ajax:

 <body>
 <div id="main_content">

 <!--this is where the ajax is returning the info-->
 </div>
 </body>

 <body>
 <div id="main_event_saff">

 <!--this is an example of the ajax returns-->
   <table>
  <tbody>
<tr>
<td class="header">Header</td>
 </tr>

 <tr>
<td class="data">Data</td>
</tr>
 </tbody>
  </table>
 </div>
 </body>

Ajax file:

 $(document).ready( function rankings(callback){

 $.ajax({

   url: 'ajax/rankings.php',
   type: 'GET',
   success: function(response){

      $('#main_event_saff').html(response);

   }

 });

});

Here's the plugin that I want to read the response of the ajax request:

 $(document).ready(function () {
 $(".data").hide();

$(".header").click(function () {
    $(this).next(".data").slideToggle(200);
});

});

This doesn't work because it can't read the ajax request

just like the page source it only see's

  • 写回答

4条回答 默认 最新

  • csdnceshi62 2014-03-28 04:50
    关注

    As you said you are using jQuery, why not this

      $(document).ready( function rankings(callback){
         $.ajax({
             url : 'ajax/rankings.php',
             type : 'GET',
             data : 'yourData',
             success : function(response){
               $('#main_event_saff').html(response);                
             }
    
         });
      });
    

    this will make your work easy

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料