简体   繁体   English

如何检查是否可以使用javascript连接到URL?

[英]How can I check if I can connect to a URL using javascript?

How can I check if I have a connection with a URL? 如何检查我与URL的连接? Could be something like trying to download a image, something like if the server is online. 可能类似于尝试下载映像,例如服务器在线。 Would it be possible using javascript to do something like this? 可以使用javascript来做这样的事情吗?

I assume you would need to use Ajax to hit the URL. 我认为您将需要使用Ajax来访问URL。 If you don't get an error like 404 in the response then you have access to the URL. 如果您在响应中未收到类似404的错误,则可以访问该URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM