Add error catching in AJAX onreadystatechange