Is it possible in $.getScript() to create a condition where if the first js script fails to load – for whatever reason – then run the second js? Like a backup?
Any way to make this work with jQuery 1.2 and/or 1.4?
Thanks a lot!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As long as you’re using jQuery 1.5 or greater then $.getScript() returns a Promise so you can attach a function to both success and failure. They show an example in their documentation where they attach to fail like so:
There’s no reason why you couldn’t do another $.getScript() within the function that .fail() calls.