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 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?