JQuery: Failed to load resource: net::ERR_FILE_NOT_FOUND
If you are getting the above error that means the html page
is unable to load the Jquey library file which you are using.
1.
If you are trying to load JQuery library from
CDN, then make sure to mention the http:// or https:// in the script tag.
For ex:- if you mention the src
file as below, then by default it will look for file://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js
which it is unable to load so giving the error File not found.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
The correct syntax is to mention
the complete url starting with http:// as below.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
2.
If you are trying to load the JQuery library
file from local repository, make sure to give the correct path to the library
file. If you have the below directory structure, then reference the .js file as
<script src="jquery/jquery-1.11.1.min.js"></script>
dir1
|------sample.html
|------jquery
|---------jquery-1.11.1.min.js
Failed
to load resource: net::ERR_FILE_NOT_FOUND
file:///D:/Jquery/text/javascript
If
you are getting the above error, that means html is unable to load “text/javascript”
that is mentioned in the script tag. It may be because of the incorrect syntax
of the <script> tag.
In
my case I have mentioned “src” attribute instead of “type” in the script tag
like below.
<script src="text/javascript"></script>
Correct syntax is to use type attribute
<script type="text/javascript"></script>
After changing this, the error is gone. So make sure to
check on the syntax.