Jquery, append content from url

10,316

Solution 1

You could try this:

$.get('/someurl', function(result) {
    $('#someElement').append(result);
});

Solution 2

So you are trying to append dynamic content? Try something like this:

$(document).ready(function(){
  $.get('<URL>', function(data){
    $(<contentelement>).append(<either entire data element, or do some operations on it>);
  });
});
Share:
10,316
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    Is there anyway to append some html content from a file in Jquery?

    I know you can use load() in jquery to replace the entire content within an element.

    but I wonder if I can conditionally use append('url') to add extra content into an element in Jquery