Added error checker in XHR response