javascript - jQuery filters out inline AJAX request when page AJAX'd in -
i have history api script loads in content url pages main div , changes url accordingly. reasons shall not explain brevity, having use inline script in page load in audio player. when page player ajax'd in history api inline script removed.
i have had problems jquery's ajax function filtering out inline scripts before got round in history api script:
var dom = $(responsedata); dom.filter('script').each(function(){//function allow inline javascript $.globaleval(this.text || this.textcontent || this.innerhtml || ''); }); that not working in case of inline script:
//append player js doesn't show when js disabled $('#profile_content').append('<div class="artistfeeditem" data-type="track" data-id ="<?php echo $e_id; ?>" data-ts ="<?php echo $ts; ?>"><img src="../files/images/bigloader.gif" style="display:block;margin-left:auto;margin-right:auto;"></div>'); //loading $('*[data-type="track"].artistfeeditem').each(function () { //get player track , send off variables var e_id = "<?php echo $e_id; ?>"; var t_id = "<?php echo $t_id; ?>"; var t_url = "<?php echo $t_url; ?>"; var t_name = "<?php echo $t_name; ?>"; var t_timestamp = "<?php echo $t_timestamp; ?>"; var t_pic = "<?php echo $t_pic; ?>"; var a_name = "<?php echo $name; ?>"; $.ajax({ url: 'player/body_player_template', type: 'get', data: { t_url: t_url, t_name: t_name }, success: function (responsedata) { $('*[data-type="track"]*[data-id="' + e_id + '"].artistfeeditem').html(responsedata); }, error: function (xhr, textstatus, errorthrown) { $('*[data-type="track"]*[data-id="' + e_id + '"].artistfeeditem').html("sorry, track couldn't loaded. try refreshing page."); } }); }); that's inline script being filtered out when ajax'd in.
i hope understand i'm asking , hope there way prevent happening.
don't know why didn't spot long scripts being executed before dom loaded. have changed functions around scripts executed after new dom loaded in.
Comments
Post a Comment