Failed to load resource: the server responded with a status of 404 () - javascript

I have written a small code using index.html and three .js files. It was working fine if i run it through my local. As soon as i uploaded it to github and hosted my webpage and opened it the above error is coming. i am attaching the url of my github page : https://sravya160597.github.io/courseracss/mod4_solution/index.html
please help me if anyone has a solution for this.

Taking a look at the page source, and comparing to your github repository, it appears that the problem is case sensitivity in github pages (whereas your localhost must be case-insensitive). Both your SpeakHello.js and SpeakGoodBye.js should start with a lowercase, as follows:
<head>
...
<script src="js/speakHello.js"></script>
<script src="js/speakGoodBye.js"></script>
<script src="js/script.js"></script>
</head>

Related

Angular.js error

I'm working on a project where I'm trying to allow me to upload weather data from an .xls file to an SQL database. It's my first time using Angularjs so I used a tutorial and everything seemed to work fine.
My code is:
<head>
<title>.: Import Data with AngularJS :.</title>
<meta charset="utf-8" />
<script type="text/javascript"
src="C:\Users\Bryan\source\repos\Weather\weather\Scripts\jquery-
1.10.2.min.js"></script>
<script type="text/javascript"
src="C:\Users\Bryan\source\repos\Weather\weather\Scripts\angular.min.js">
</script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular-
route.min.js"
<script type="text/javascript"
src="C:\Users\Bryan\source\repos\Weather\weather\Scripts\bootstrap.min.js">
</script>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.cs
s">
<script type="text/javascript"
src="C:\Users\Bryan\source\repos\Weather\weather\Scripts\ImportData.js">
</script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.11.5/xlsx.full.min.js">
</script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.11.5/jszip.js"></script>
Everything goes well but I get the following errors:
ImportData.html:7 GET http://localhost:9000/Content/bootstrap.min.css
net::ERR_ABORTED
ImportData.html:1 Not allowed to load local resource: ImportData.js
angular.js:88 Uncaught Error: [$injector:modulerr]
at angular.js:88
at angular.js:4957
at p (angular.js:410)
at g (angular.js:4917)
at gb (angular.js:4839)
at c (angular.js:1949)
at Uc (angular.js:1970)
at xe (angular.js:1855)
at angular.js:33826
at HTMLDocument.b (angular.js:3468)
I've read that bootstrap and angular can conflict, but take it out and it still seems to error out. Any ideas where the error is? Thanks in advance.
Your files are not able to fetch by the browser from the mentioned locations. So better way to give relative paths i.e. "../../ImportData.js".
Also It shows injector module error that means, Angular file is missing and its module is not able to find the libraries.
You can try replacing all the file paths with as well. Also this http://localhost:9000/Content/bootstrap.min.css
net::ERR_ABORTED
is due to the internet failure or due to your firewall restrictions. So, you can replace this with "https" instead of 'http'.
Try these options. There's problem with file links only.
The problem is that you are trying to load resources from your local computer. Try giving path as relative that will solve your issue. Also use base url in html if you want to control base url for all requests from your app.

Fixing js "Script error"

I'm having difficulties implementing something simple: I have an index.html file served on http://localhost:3200 by ruby on rails, which uses a javascript file served on http://localhost:8000 by webpack-dev-server.
So here's what I have:
<!doctype html>
<head>
<script crossorigin="anonymous" src="http://localhost:8000/app.js" />
</head>
<!-- ... -->
</html>
My app.js file is sent with, amongst others, the following header:
Access-Control-Allow-Origin: *
What I want is to be able to override window.onerror in app.js, and see caught errors, rather than "Script error".
What am I missing?
-- edit --
Since it might not be clear enough: my script does load. I have no problem with that. My issue is that I need to report errors that happen to somewhere else, but I can't do that since any error that occurs in app.js is reported as "Script error" rather than something more explicit.
What sourcemap (devtool) are you using?
I was getting this issue, and it changing from eval-source-map to source-map fixed it.
This is a google chrome issue, should be when Chrome 71 is released.
Here are the relevant issue threads:
https://bugs.chromium.org/p/chromium/issues/detail?id=765909
https://github.com/webpack/webpack/issues/5681
Edit: This also impacts electron users.

Web page cannot load javascript files from primefaces library

I use primefaces 6.0 and Spark-layout in my project.
It works on localhost very well.
But when I upload it to the server (jboss or tomcat does not differ), sometimes the page cannot load.
It happens randomly. The page stucks while loading.
When I look the server logs :
It waits too much to log this line:
"GET /XXX/javax.faces.resource/images/preloader.gif.xhtml?ln=spark-layout HTTP/1.1" 200 17824
Also I have seen this in log :
"WARNING [http-nio-80-exec-27] com.sun.faces.application.resource.ResourceHandlerImpl.logMissingResource JSF1064: Unable to find or serve resource, components.js, from library, primefaces."
I have continued to investigate, and seen that, when the problem occurs, the page waits to load .js files from primefaces library.
Page stucks at this line in the head :
script type="text/javascript" src="/XXX/javax.faces.resource/jquery/jquery.js.xhtml?ln=primefaces&v=6.0">
Other .js files cannot be loaded:
script type="text/javascript"
src="/XXX/javax.faces.resource/jquery/jquery-plugins.js.xhtml?ln=primefaces&v=6.0">
script type="text/javascript"
src="/XXX/javax.faces.resource/core.js.xhtml?ln=primefaces&v=6.0">
As a result, what can I do to get rid of this problem :)
Thanks...

Why does Firefox DevTools' Debugger show 'loadSourceError'?

Consider this simple HTML file:
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
alert('1');
</script>
</body>
</html>
When I enable Firefox JavaScript Debugger (via Ctrl+Shift+S), the panel shows me the following error message instead of the source code:
Error loading from source:
loadSourceError
What am I doing wrong?
My bet is that it comes from some server setting, since it works fine from another server (as well as locally), but I cannot identify any noticeable difference between both configurations (apache.conf are identical, /etc/apache2/sites-enabled/ configuration is similar, enabled modules are the same. I had the hope that installing the javascript-common debian package would help, but it does not…).
JavaScript itself is served correctly, though (even the embedded JS), and there is no loading problem for JS files.
Got it!
It seems that the debugger has issues with internationalized domain names (IDN).

Resource interpreted as Script but transferred with MIME type text/plain - for local file

I'm getting a "Resource interpreted as Script but transferred with MIME type text/plain" warning in Google Chrome when including a local script file.
I know the problem appears when loading a file from a server or through ajax which most often depends on wrong headers being set.
The weird thing is that I get this warning even though it is run from a local folder: file:///C:/test/foo.html
This happens only in Chrome with the most basic html there is:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="bar.js"></script>
</head>
<body>
</body>
</html>
bar.js is also as simple as it can get:
function hello() {}
I've tried adding a meta tag:
<meta http-equiv="content-script-type" content="text/javascript">
and tested with other doctypes but nothing seems to help.
This obviously isn't a real issue since the scripts still work fine, but I'm working on a large project and currently have around 150 scripts included. It therefore makes it difficult to see when an actual warning occurs in between them.
Everything works fine when I run the file on a server, locally or remote.
Any ideas on why chrome is annoying me with this?
I figured it out!
The Visual Studio installer must have added an errant line to the registry.
open up regedit and take a look at this registry key:
See that key? The Content Type key? change its value from text/plain to text/javascript.
Finally chrome can breathe easy again.
I should note that neither Content Type nor PercievedType are there by default on Windows 7, so you could probably safely delete them both, but the minimum you need to do is that edit.
Anyway I hope this fixes it for you too!
I tried fixing this problem using this method but it didn't work for me.
My problem was that IIS manager didn't have MIME types in HTTP Features.
I was able to turn it on by enabling Static Context via...
--> Control Panel
--> Programs
--> Turn Windows features on or off
--> Internet Information Services
--> World Wide Web Services
--> Common HTTP features
--> [X] Static Content.
After this, MIME types appeared and everything started working again.
The accepted answer is a great one! However, just to post an answer for those who encounter problem like me, who use a department/college computer sometimes, where I do not have the permission to change any key value in regedit.
Change
<script type="text/javascript" src="main.js"></script>
to
<script src="main.js"></script>
Although the error message still exist, the page loaded correctly.

Categories