$.ajax({
    url: '/getuserrole/',
    dataType: 'json',
    cache: false,
    success: function (data) {
        if (data.loggedin == 0) {
            window.location = '/backend/index.html';
            return;
        }

        if (data.role != 1) {
            window.location = '/backend/backendindex.html';
            return;
        }
    },
    error: function (xhr, status, err) {
        console.error(status, err.toString());
        window.location = '/backend/index.html';
    }
});