开发者

Can I get data from an ajax request using a global .ajaxSuccess handler?

I've created a global handler for ajaxSuccess, but I need to be able 开发者_StackOverflow社区to examine the data for each request. Is it possible to access the returned data at this point?

jQuery(document).ajaxSuccess(function(event, request, options) {
    // i can has the datas? >^..^<
});


This works in FF, Chrome, IE 8:

jQuery(document).ajaxSuccess(function(event, request, options) {
    if (options.dataType == 'json') {
        var data = JSON.parse(request.responseText);
        // i has the datas!
    }
});


jQuery(document).ajaxSuccess(function(event, request, options, data) {
        console.log(data);
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜