开发者

jquery scripts inside a page called via an ajax call

开发者 https://www.devze.com 2022-12-09 23:16 出处:网络
So, these script don\'t want to work. Not sure what to do. If i run the page B by itself, everything works fine. If the page A makes an ajax call to page B, none of the scripts within there would work

So, these script don't want to work. Not sure what to do. If i run the page B by itself, everything works fine. If the page A makes an ajax call to page B, none of the scripts within there would work. What do i do? thanks in advance.

the code in page B:

  chkBox = function() {
       jQuery("#docheckchildren").checkboxTree({
   collapsedarrow: "../img/img-arrow-collapsed.gif",
   expandedarrow: "../img/img-arrow-expanded.gif",
   blankarrow: "../img/img-arrow-blank.gif",
   checkchi开发者_运维百科ldren: true,
   checkparents: false
   });
}

page A ajax call:

$.ajax({  
     type: "GET",        
     url:"mypage.cfm",
     data:formData,        
     cache:false,       
     success: function(res) { 
     $('#dsp_Grid').html(res);
     chkBox();
     }
    , error: function(xmlHttpRequest, status, err) {
        confirm('Error! ' + status +':'+ err);
     }
  });

page B: if i have to run it by itself, I have to add the following: << the href is different in top pageA: Seems to work since I see the css for the checkboxes.

(Same, src is different in pageA)

I think part of the problem is I am loading whatever returns from pageB to a div in pageA by

$('#dsp_Grid').html(res)


You can either:

  1. Use a call back function in the AJAX call that calls the scripts that is loaded via AJAX or
  2. Use the live query feature that will apply whatever functionality on your page to the newly loaded content.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号