THRIFT-3328 A callback is not called when a server is down.

https://issues.apache.org/jira/browse/THRIFT-3328
diff --git a/lib/js/src/thrift.js b/lib/js/src/thrift.js
index 664171e..34be450 100644
--- a/lib/js/src/thrift.js
+++ b/lib/js/src/thrift.js
@@ -343,6 +343,16 @@
                   }
                 };
               }());
+
+            // detect net::ERR_CONNECTION_REFUSED and call the callback.
+            xreq.onerror =
+                (function() {
+                  var clientCallback = callback;
+                  return function() {
+                      clientCallback();
+                  };
+                }());
+
         }
 
         xreq.open('POST', this.url, !!async);