开发者

jQuery ajax function not working

开发者 https://www.devze.com 2023-03-05 04:40 出处:网络
$(\"a[rel=profile]\").live(\'click\',function() { var profileURL = $(this).attr(\'href\') $.ajax({ url: profileURL,
$("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

精彩评论

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