Asked  6 Months ago    Answers:  5   Viewed   29 times

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?



It means that the server is sending a Javascript HTTP response with

Content-Type: text/plain

You need to configure the server to send a JavaScript response with

Content-Type: application/javascript
Tuesday, June 1, 2021
answered 6 Months ago

Seems to me like the problem is in your IIS configuration. it might be configured to deliver .css files with text/html MIME type.

Try going to the MIME types configuration on the web server and see if you can spot anything there.

The correct MIME type for .css files is text/css.

You can also have a look on the HTTP header parameters with some HTTP sniffer such as fiddler.

Updating: The accepted answer should be the one pointed by @brett-pennings! Just providing static contents, the error vanished automatically.

Wednesday, July 28, 2021
answered 4 Months ago

Hit F12 and then go to Network tab. If you want html document then narrow the filter to Documents (on the bottom).

Tuesday, August 3, 2021
Miguel Ping
answered 4 Months ago

For Firefox, there is an add-on provides almost the function you wanted: . No idea if there is a Chrome extension or not.

Even if the functionality exists, I wouldn't recommend you to use it in your example: Arbitrary HTML would have access to domain for cookie and script, which is really really bad in terms of security.

Thursday, September 9, 2021
answered 3 Months ago

You're setting mimeType during initialization based on one file that you might be sending out, rather than setting it based on the file that you're actually sending out. That will cause any non-HTML files that you might send (e.g CSS or JS files) to go out with a misleading Content-Type header. You need to do the check inside your request handler.

Tuesday, November 16, 2021
answered 2 Weeks ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :