Add AJAX support for error handler, fix minor bugs in AJAX upload