tags:

views:

20

answers:

1

I've created a global handler for ajaxSuccess, but I need to be able 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? >^..^<
});
A: 

This works in FF, Chrome, IE 8:

jQuery(document).ajaxSuccess(function(event, request, options) {
    if (options.dataType == 'json') {
        var data = eval('(' + request.responseText + ')');
        // i has teh datas!
    }
});
Daniel Schaffer