0

Is it possible to select only specific part from the return data?

this is my code

$(document).ready(function(){
    $("a[href*='delete']").click(function(){
        var url = $(this).attr('href');
        url = 'http://localhost'+url;

        $.ajax({
            type : 'GET',
            url : url,
            success : function(data){
                $('#table_div').html(data);
            }
        });
        return false;
    });
});

if I use above codes it set the complete page to #table_div. so I need to select only that #table_div data form the data. how do I do that ?

user1784592
  • 129
  • 1
  • 3
  • 11

1 Answers1

0

have you tried this ?

$(data).filter('#table_div');
$(data).find('#table_div');

see this reference

Hope, it will helps you. Thanks. !!

Community
  • 1
  • 1
immayankmodi
  • 8,210
  • 9
  • 38
  • 55
  • when I add .filter(), it isn't work but It work for .find() . do you have any idea? – user1784592 Dec 01 '12 at 14:56
  • `filter` will search through all element whereas `find` will search only in the descendent list. – immayankmodi Dec 01 '12 at 15:12
  • this is my code$.ajax({ type : 'GET', url : myurl, success : function(data){ $('#table_div').html($(data).filter('#table_div')); } }); – user1784592 Dec 01 '12 at 15:16
  • Try this: `$('div').filter( $('#table_div'))` like this `$("div").filter( $("#unique") )` see ref http://api.jquery.com/filter/ `Filter` actually returns the items chosen in the previous selector which also match the the selector in the filter method. Is it helpful to you ? – immayankmodi Dec 01 '12 at 15:37