Hey. How can I solve the problem:

  1. - in case of successful loading of the script, call up the connection of another file (and its execution) and then execute the source file.

  2. -If the connection fails, call the error.js file.

I understand that I ask a lot. I found http://javascript.ru/blog/Ilya-Kantor/Zagruzka-dannyh-cherez-SCRIPT-s-otlovom-oshibok , but it works incorrectly for me. Interests while the option on pure JS.

  • one
    Try to think about the architecture better. - ReklatsMasters

1 answer 1

Try downloading the script with dataType=='text' , if successful, you can run it through eval() , although this is not beautiful.

If the script is stranger, then when loading via jsonp it will try to execute first. You can try to execute "your" correct script before starting its loading and hide its result, and in case of an error of loading the required script, roll back (or just not show the result of your actions) and execute the script for the error.