'Makes an AJAX request at a given action.
Pass an action and relevant arguments for that action.'

def request(self, action, autologin=True, **kwargs):

    def make_request(action, **kwargs):
        ajaxpage = 'ajax.php'
        content = self.unparsed_request(ajaxpage, action, **kwargs)
        try:
            if (not isinstance(content, text_type)):
                content = content.decode('utf-8')
            parsed = json.loads(content)
            if (parsed['status'] != 'success'):
                raise RequestException
            return parsed['response']
        except ValueError:
            raise RequestException
    try:
        return make_request(action, **kwargs)
    except Exception as e:
        if (autologin and (not self.logged_in())):
            self._login()
            return make_request(action, **kwargs)
        else:
            raise e
