Skip to content Skip to sidebar Skip to footer

Running Javascript In Page That Is Loaded With Jquery Ajax

I have a function that loads parts of other pages into my div #ajaxloadconent, here is the function: $('#ajaxloadcontent').load(url+' #ajaxloadcontent'); However, the problem is t

Solution 1:

Try to use this

$.ajax({
  url: url,
  dataType: 'html',
  success: function(data) {
    //Do something with the data e.g.
    $(data).find("#ajaxloadedcontent").appendTo("#ajaxloadcontent");
  }
});

from the jQuery docs:

"html": Returns HTML as plain text; included script tags are evaluated when inserted in the DOM.

Or you can use http://api.jquery.com/jQuery.getScript if you seperate your script to a standalone js file

Post a Comment for "Running Javascript In Page That Is Loaded With Jquery Ajax"