js file can not be loaded summary

There is a problem that the class in the js external file loading cannot be loaded:

        First check whether there is an error in the js file path; if the file has not been loaded, it is likely that there is a problem with the js file path;

        Secondly, if there is no error in the path, and when loading the js file, the file can still be loaded at the beginning of the process of writing the js file. Later, the js file cannot be loaded due to adding or modifying the script of the js file. It is caused by wrong syntax in the script; at this time, you need to check the js file information carefully; there is also a quick way to locate the js file error (with code attached):

function dynamicLoad(){
			 var _doc=document.getElementsByTagName('head')[0];
			 var script=document.createElement('script');
			 script.setAttribute('type','text/javascript');
			 script.setAttribute('src','${contextPath}/static/pagejs/enterprisemanage/enterpriseDataOption.js');
			 _doc.appendChild(script);
			 script.onload=script.onreadystatechange=function(){
			 if(!this.readyState||this.readyState=='loaded'||this.readyState=='complete'){
			 alert('done');
			 }
			 script.onload=script.onreadystatechange=null;
			 }
			}

 This code is used to detect whether the js file is loaded, add this code to the current page, and then make this code execute when the page loads, open the developer mode of the browser at this time and refresh the page with the error, at this time it will pop up 'done' pop-up box, and then you will find the wrong place in the js file in the browser's console;

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326377863&siteId=291194637