jQuery ajax() gets net::ERR_CONNECTION_TIMED_OUT on Chrome, not Firefox or Safari
I'm using Chrome 58.0.3029.68 beta (64-bit) on OSX 10.12.4, with jQuery 3.2.1. I want to use an ajax call to an IP address/DNS name to see if the host is (still) responding.
I set up the ajax() call as below. Most of the time, a non-existent device/address returns the expected 'timeout' as the textStatus. (Note: Hosts that
do respond will generally return 'error', because this looks like a CORS violation.)
- $.ajax({
- url: "http://127.0.0.20",
- crossDomain: false,
- timeout: 6000,
- cache: false,
- data: {
- name : "http://TestMyInter.net"
- }
- })
- .always((jqXHROrData, textStatus, jqXHROrErrorThrown) => {
- console.log(`In completion: textStatus is: ${textStatus}`);
- });
But... from time to time, Chrome (but not Firefox or Safari) will display "net::ERR_CONNECTION_TIMED_OUT" in the browser's Console window, and the textStatus will be set to 'error'.
My questions:
- Why does Chrome return this status, and not Firefox or Safari?
- Is there a way to detect the ERR_CONNECTION_TIMED_OUT state in the completion routine?
- What other information could I provide?
Many thanks!