I am getting:

    TypeError: data is null
    $('#' + type + '_correlation').html('<h3>' + data.reason +

I am guessing for some request there is no data coming back so, just wrapping that bit of code in an if/if..else will avoid the error from happening.

    if(data !== null) {
        $('#' + type + '_correlation').html('<h3>' + data.reason + .....
    } .....