开发者

jQuery JSON call returning null

I am calling a JSON source with jQuery that looks like this:

{
   total: 1,
   current: 0
}

My jQuery script below is returning NULL from the json call and I can't work out why? The data source is correct and working.

    $.ajax({
        url: source,
        cache: false,
        beforeSend: function(){
            target.before('<div class="feed-loading"></div>', function(){
                target.slideUp();
            });
        },
        success: function(html){

            /* load feed data into target */

            target.html(html).slideDown();
            $('.feed-loading').fadeOut();

            /* updates attendances */

            $('.actionpanel a.attend').each(function(index) {

                var event_id = $(this).attr('rel');

                /* find if logged in user is attending */

                $.getJSON(settings.base_url + 'ajax/event_attendance/' + event_id, function(attendance) {

                    console.log(attendance);

                    /* update attendance figures on page */

                    $('a.attend[rel="' + event_id + '"]').nextAll('.meta').text(attendance.total + ' attending');

                    if (attendance.current == 1) {
                        $('a.attend[rel="' + event_id + '"]').addClass('selected').attr('title', 'You are attending!'开发者_如何学C);
                    };

                });

            });
        }
    });

I think it must be something to do with the fact its within another ajax call as I have used similar code elsewhere and its worked ok.


I think your JSON is bad -- you're missing a comma. Try this:

{
   total: 1,
   current: 0
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜