Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
146
rated 0 times [  151] [ 5]  / answers: 1 / hits: 21096  / 10 Years ago, wed, november 5, 2014, 12:00:00

I want to catch all errors with the help of TRY {} CATCH(){} when I send data to a server via XMLHttpRequest.



How can I receive all errors, such as net::ERR_INTERNET_DISCONNECTED, etc. ?


More From » ajax

 Answers
1

Refer this,



function createXMLHttpRequestObject()
{
// xmlHttp will store the reference to the XMLHttpRequest object
var xmlHttp;
// try to instantiate the native XMLHttpRequest object
try
{
// create an XMLHttpRequest object
xmlHttp = new XMLHttpRequest();
}
catch(e)
{
try
{
xmlHttp = new ActiveXObject(Microsoft.XMLHttp);
}
catch(e) { }
}
// return the created object or display an error message
if (!xmlHttp)
alert(Error creating the XMLHttpRequest object.);
else
return xmlHttp;
}

[#68904] Monday, November 3, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dylondaytond

Total Points: 92
Total Questions: 88
Total Answers: 96

Location: China
Member since Fri, Jan 15, 2021
3 Years ago
dylondaytond questions
Tue, Jun 22, 21, 00:00, 3 Years ago
Thu, May 7, 20, 00:00, 4 Years ago
;