Peminator
Peminator

Reputation: 852

jquery get fragment gets whole page

anybody has experienced this, what may be wrong? basically I use get ended with space followed by id/hash of element on other page but jquery always loads whole page....

snippet here:

var url = $(this).attr('href'); 
url = url+' #detail';
console.log('LOADING '+url);
$.get( url, function(dt){datadetail = dt;} );
$('#result').append(datadetail);

there is element with id="detail" on the other page, both pages on same domain, yet it always loads whole page instead of fragment... what may be wrong?

Upvotes: 0

Views: 71

Answers (1)

adeneo
adeneo

Reputation: 318162

$.get doesn't work that way, there is no filter. Only load() has that, and it still gets everything, it just filters before outputting.

What you want is something like

var url = $(this).attr('href'); 

$.get( url, function(dt){
    var datadetail = $('<div />', {html : dt}).find('#detail');
    $('#result').append(datadetail);
});

Upvotes: 3

Related Questions