开发者

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

开发者 https://www.devze.com 2022-12-25 06:44 出处:网络
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?

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

精彩评论

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