script.js icon indicating copy to clipboard operation
script.js copied to clipboard

File not found

Open ghost opened this issue 12 years ago • 9 comments

Is there any way to know if file is not found (404)

Example

$script('someFileNotOnServer.js', function() { /* The code over here throws error. */ })

ghost avatar Jul 12 '13 17:07 ghost

not at the moment. the callback will fire regardless of whether it returns 404 or 200

ded avatar Jul 12 '13 20:07 ded

Once https://github.com/ded/script.js/pull/48 is merged you'll be able to have to declare a fallback function. Using it would look something like below.

$script('someFileNotOnServer.js', function() {
/* someFileNotOnServer.js' Found */
}, function(deps) {
/* someFileNotOnServer.js' Not Found */
})

willfarrell avatar Jul 31 '13 20:07 willfarrell

:+1: This would be very useful to me.

NickHeiner avatar Feb 28 '14 21:02 NickHeiner

Alright I'll try and sort this out soon

ded avatar Mar 02 '14 06:03 ded

Any timeline on when this will be merged? I'm in desparate need of this type of logic and would like to stick to $script. Thanks

Kikketer avatar Oct 30 '14 15:10 Kikketer

Cool stuff, error (404) and success (200) callbacks, can't wait for the PR merge

isocroft avatar Nov 27 '14 16:11 isocroft

Hi, any news on when this functionality will be merged in?

cheers, florian

zenwork avatar Aug 16 '15 14:08 zenwork

If you are only targeting IE9+ see: https://github.com/ded/script.js/issues/84

amorey avatar Aug 16 '15 16:08 amorey

Hi! I using this flow with Angular, but it's not work like it suppose to be. I rewrited it using $script.ready(function(){},function(){}) but it goes throw second function, no matter file was found or not. I need to catch error when flow goes in the way that user have no ability to get files. How could I do it?

fridmaster avatar Jun 10 '17 08:06 fridmaster