Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery ajax load certain div

Tags:

html

jquery

ajax

my question is very simple how can I retrieve certain div with jquery ajax comand

$.ajax({
      url: "test.html",
      success: function(){
           $(this).addClass("done");
      }
  });

like with load

$('#targetDiv').load('http://localhost/test.html #sourceDiv');
like image 739
Yovo Avatar asked Apr 10 '11 12:04

Yovo


1 Answers

If the div is part of the AJAX response:

$.ajax({
    url: 'test.html',
    dataType: 'html',
    success: function(html) {
        var div = $('#sourceDiv', $(html)).addClass('done');
        $('#targetDiv').html(div);
    }
});
like image 170
Darin Dimitrov Avatar answered Oct 10 '22 02:10

Darin Dimitrov