JQuery if exists

How to check if a file exists on the current site?

how

if ('http://site.com/girlfirend.png' exist) {
// do something
}

Maybe I can use .get? But how to check its status (ok or 404)?

Thank.

+3
source share
2 answers

Issue a request for a file and check the result.

See Ajax in jquery

+3
source

Use jQuery, the following message is given here:

How to check if a file exists in javascript?

+1
source

Source: https://habr.com/ru/post/1750455/


All Articles