How to catch the error thrown by an invalid URL using XMLHttpRequest
问题 I have not worked much with the XMLHttpRequest object in JavaScript . I am new to it. I have done many jQuery Ajax calls, but have not worked in much detail with the XMLHttpRequest object. I am working through a book where they give some sample code using this object. Here is some code the book uses when trying to deal with errors. It is supposed to catch the error thrown by the incorrect URL. But I can't get it to go it the catch clause : var httpRequest = new XMLHttpRequest(); try {