doumu8911 2010-01-05 07:39
浏览 37
已采纳

关于curl的Jquery获取数据

I have a div which is being populated through curl from another html page .Now the data is populating correctly but i want to use jquery or javascript on the ids or classess of the fetched data. I tried using livequery ,binding but of no use. Can you please help me .

  • 写回答

1条回答 默认 最新

  • dongzhi4498 2010-01-06 01:03
    关注

    Are you wrapping your javascript with $(document).ready(function() { } ); as to ensure the dom is fully loaded?

    For instance:

    $(document).ready(function() { $('#id').click(function() { // do stuff } ); }
    

    This would fix the issue if the HTML fetched via CURL is being populated via a direct post-back. If you're populating the data asynchronously, then you'll either have to use the .live() mechanism for binding (through read the docs carefully, live() doesn't work in certain scenarios and was added in the most recent version of jQuery -- so check that you've got the right version of jQuery and that you're not trying to use events that aren't supported with that binding mechanism). Furthermore, live is a bit of performance tax, so I'd do something like.

    $.ajax({ // Lots of ommitted options for simplicity's sake 
              success: function(data, status) { 
                   $('#targetDiv').append(data);
                   $('#targetDiv #elementID').click(function() { // do stuff });
              }
            });
    

    Hopefully this helps steer you in the right direction. With a code sample we could certainly help more.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 网络科学导论,网络控制
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)