javascript - Get Same Function used to load ajax content work on ajax content -


i want load site via ajax using this, code explains more can:

<script>     function lage(url){   $.get(url, function(data) {     $('#plus').html(data);     $('[href]').each(function() {     var el = $(this);     var val = el.attr('href');     var sal=  'lage(\'' + val + '\')';     el.removeattr('href')        .attr('onclick', sal); });   }); } </script> <body  onload="lage('http://crossorigin.me/http://anycorssite')"> <div id="plus"></div> 

the lage() function not working on ajax loaded content working on onload event.

you this:

<script>      function lage(url){       $.get(url, function(data) {         $('#plus').html(data);       });     }      var initialurl = $('body').data('initialurl');     lage(initialurl);      $('body').on('click', 'a', function (e) {       var url = $(e.currenttarget).attr('href');       lage(url);       e.preventdefault();     });  </script>  <body data-initial-url="http://crossorigin.me/http://anycorssite"> <div id="plus"></div> 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -