My current challenge involves sending a JSON-encoded data string to a remote machine via AJAX. Every time I attempt to transmit the data string, one of two error messages emerges:
XMLHttpRequest cannot load http://10.1.0.139:8000/.
No 'Access-Control-Allow-Origin' header is present on
the requested resource. Origin 'http://localhost' is
therefore not allowed access.
This message occurs when the remote machine is operational and accepting connections. Despite this error, my code successfully sends the correct data string to the remote machine.
POST http://10.1.0.139:8000/ net::ERR_CONNECTION_REFUSED
The second message appears when the remote machine is turned off or doesn't have its own server running to accept incoming requests and connections.
My main issue lies in distinguishing between these two error messages. Traditional AJAX callbacks like error() or fail() are not effective since there will always be an error, even if the HTTP status 200 confirms that everything is functioning correctly (as shown by the first error).
Is there any way to implement a pseudo command that states 'IF I FAIL TO CONNECT TO REMOTE MACHINE, THEN...'
EDIT
Upon further observation, my remote machine fails to display incoming connections made from Internet Explorer, instead showing the following:
XMLHttpRequest: Network Error 0x2efd,
Could not complete the operation due to error 00002efd.