开发者

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;
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜