jQuery ajax function not working
$("a[rel=profile]").live('click',function() {
var profileURL = $(this).attr('href')
$.ajax({
url: profileURL,
success: function(data) {
alert(data)
$("#profile").html(data);
$("#profile").fadeIn();
}
});
return false;
})
Can any开发者_Go百科one tell me what is wrong with this code, when I click the link with rel=profile
it fires the alert()
with the remote URL content but doesn't load it into the div
and then fadeIn()
Thanks in advance :)
Why don't you just try something like this instead. See the API for the Load
function. You can also pass it a callback
so you can do something after the load is complete like so:
$("a[rel=profile]").live('click', function() {
$('#profile').load(
$(this).attr('href'),
function(){ $('#profile').fadeIn();});
return false;
});
精彩评论