-3

On all browsers: Resource interpreted as Script but transferred with MIME type text/plain:"file:///E:/Projetions%20Matcher/Canvas/jquery.min.js".

So jquery.min.js is loaded, but livello.js isn't. Why?

EDIT: I attempted to load it on a server but there was the same error

HTML: ....

<script src="jquery.min.js" type="text/javascript"></script>
<script src="livello.js" type="text/javascript"></script>

....

livello.js:

var c=document.getElementById("app"); 
var ctx=c.getContext("2d");

function resize(){
c.style.width = window.innerWidth + 'px';
c.style.height = window.innerHeight + 'px';
var gameWidth = window.innerWidth;
var gameHeight = window.innerHeight;
var scaleToFitX = gameWidth / c.width;
var scaleToFitY = gameHeight / c.height;
var currentScreenRatio = gameWidth / gameHeight;
var optimalRatio = Math.min(scaleToFitX, scaleToFitY);
  c.style.width = c.width * optimalRatio + "px";
    c.style.height = c.height * optimalRatio + "px";
}
window.onresize=function(){resize();};

function clean()
{c.width=window.innerWidth;
c.height=window.innerHeight;}

clean();
DPD-
  • 39
  • 1
  • 1
  • 5
  • 1
    possible duplicate of [Chrome says "Resource interpreted as script but transferred with MIME type text/plain.", what gives?](http://stackoverflow.com/questions/3467404/chrome-says-resource-interpreted-as-script-but-transferred-with-mime-type-text) or even better http://stackoverflow.com/questions/12003107/resource-interpreted-as-script-but-transferred-with-mime-type-text-plain-for-l or http://stackoverflow.com/search?q=Resource+interpreted+as+Script+but+transferred+with+MIME+type+text%2Fplain – JJJ Dec 12 '13 at 14:16
  • Also, you should really install a server instead of opening the files directly from the filesystem. – JJJ Dec 12 '13 at 14:17
  • @Juhana: 1)no because I'm in file:/// and not in a server 2) But why jquery works also in local? – DPD- Dec 12 '13 at 14:59
  • What exactly is the problem? "Resource interpreted as script but..." is not an error but a notice. It won't cause the script to not work. – JJJ Dec 12 '13 at 15:35
  • is exactly that I want to know! Why livello.js doesn't work (but jquery.min.js works)? – DPD- Dec 12 '13 at 15:49

1 Answers1

1

In your post you say 'On all browsers' but you only tagged Google Chrome so I will try to give a solution for both scenario's.

First of all the error doesn't say that jquery.min.js is loaded. It tells you that the Content Type is set to text/plain instead of text/javascript.

With this in mind the error can be on multiple places. Here are a few common places:

1) If you are calling jquery.min.js from a web page make sure that <script type="text/javascript">

2) It could be that something you have installed messed around with the Content Type in your registry. See this link for reference and method to fix it.

3) It could also be that the error is server side. Meaning the server side application sends the Javascript HTTP response header value as text/plain again instead of text/javascript. This COULD usually be the case when the Javascript is generated from a server side scripting language. But agian there could be a few other reasons for this happening.

4) It could also be that if you are running the script locally from your computer that no Content Type is received and that is defaulted to text/plain and hence the browser is unable to process it as Javascript.

I hope that one of these will help you solve your problem.

Community
  • 1
  • 1
J2D8T
  • 759
  • 9
  • 23
  • 0) I only tagged Chrome because there's a limit of 5 tags 1)jquery works 2)I use Linux Ubuntu, and jquery works 3)I'm using the page without any server 4)Why jquery works locally (jquery.min.js and livello.js are in the same folder) – DPD- Dec 12 '13 at 15:00