Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery if exist

Tags:

jquery

file

How to check, is file exist on current site?

Like:

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

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

Thanks.

like image 690
Happy Avatar asked Oct 25 '25 11:10

Happy


1 Answers

Issue a get request to the file and inspect the result.

See Ajax in jquery

like image 109
rahul Avatar answered Oct 28 '25 03:10

rahul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!