Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery, append content from url

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

like image 434
Philips Avatar asked Feb 24 '23 15:02

Philips


2 Answers

You could try this:

$.get('/someurl', function(result) {
    $('#someElement').append(result);
});
like image 165
Darin Dimitrov Avatar answered Feb 26 '23 06:02

Darin Dimitrov


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>);
  });
});
like image 33
Vap0r Avatar answered Feb 26 '23 06:02

Vap0r