Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
440 views
in Technique[技术] by (71.8m points)

javascript - "Resource interpreted as script but transferred with MIME type text/html."

Sorry if this is actual duplicate but I haven't managed to find answer for my problem.

I load the script with jQuery's $.getScript. But it causes the following error:

Resource interpreted as script but transferred with MIME type text/html.

The problem appears only in Safari under Mac OS

If to look on headers received from the server, they contain Content-Type:application/x-javascript, so I really don't understand what the problem is.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Resource interpreted as script but transferred with MIME type text/html.

Technically that's not an error but a notice / warning and should not cause any issues in particular; if anything it's a good indication that some browsers may choose to ignore such a response.

The correct Content-Type response header for JavaScript according to the RFC is:

Content-Type: application/javascript

Previous values of text/javascript and application/x-javascript are either obsolete or deprecated respectively; that said, IE <= 8 will only accept the former so be careful when making any changes to your documents.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...