In FF and all, my javascript works fine. But in Chrome it gives this message:
Resource interpreted as script but transferred with MIME type text/plain.
I have checked all the script tags and they all have the MIME type="text/javascript"
. It even says so with jquery and jquery ui. What is wrong with Chrome?
What's the problem and the fix for this? Is it something I have to change in the 'options' of the browser or is it from the server, or do I have to tweak my code?
For Java Application servers such as Weblogic
1) Make sure your weblogic.xml file is free of errors
like this one:
2) Add a mime type for javascript to your web.xml file:
This will also work for other Java containers - Tomcat etc.
application/javascript
is currently the only valid mime-type; others liketext/javascript
have been deprecated.3) You may need to clear up your browser cache or hit CTRL-F5
A common thing when this happens is if you've simply forgotten to include the
type
in your script calls. You'll have to set it explicitly, as it is - according to W3 - required:Still it seems that browsers have a a default value of
plain/text
.Example:
You could as well set a default for that file extension in your Apache configuration:
It means that the server is sending a Javascript HTTP response with
You need to configure the server to send a JavaScript response with
If its IIS make sure That Under your
common HTTP Features
you haveStatic Content
turned onIf you are using Spring MVC, you can add following mvn tag to exclude resources file from Spring Dispatch Servlet
I received this debug message for a sillier reason than the other answers here: This is the error message received when you don't get enough sleep and reference a js file by using the syntax for a css file. As in,
rather than
Thought I'd put this up here because this is the first post that comes up when searching for the error message.