Determine if ajax call failed due to insecure response or connection refused

后端 未结 6 2145
旧巷少年郎
旧巷少年郎 2020-11-29 21:59

I\'ve been doing a lot of research and could not find a way to handle this. I\'m trying to perform a jQuery ajax call from an https server to a locahost https server running

6条回答
  •  天涯浪人
    2020-11-29 22:37

    I don't think there's currently a way to detect these error messages, but a hack that you can do is to use a server like nginx in front of your application server, so that if the application server is down you'll get a bad gateway error from nginx with 502 status code which you can detect in JS. Otherwise, if the certificate is invalid you'll still get the same generic error with statusCode = 0.

提交回复
热议问题