Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This has <strong>nothing</strong> to do with jQuery or any quirk of client-side script code. It is a <strong>server-side</strong> issue: The server(-side application) is not sending the expected HTTP <a href="http://tools.ietf.org/html/rfc2616#section-3.7" rel="noreferrer"><code>Content-Type</code> header field</a> value for the client-side script resource. This happens if the Web server is insufficiently configured, misconfigured, or a server-side application (e. g., PHP) is generating the client-side script resource.</p> <p>Proper MIME media types for ECMAScript implementations like JavaScript include:</p> <ul> <li><code>text/javascript</code> (registered as <strong>obsolete</strong>, not deprecated; but still <strong>valid</strong>, and <strong>supported best</strong>)</li> <li><code>text/ecmascript</code> (registered as <strong>obsolete</strong>, not deprecated; but still <strong>valid</strong>)</li> <li><code>application/javascript</code></li> <li><code>application/ecmascript</code></li> </ul> <p>They do <strong>not</strong> include <code>application/x-javascript</code>, as the MIME media types listed above are the ones registered in the standards tree by now (so there is no need, and there should be no want, to use experimental ones anymore). Cf. RFC 4329, "Scripting Media Types" (2005 CE) and my <a href="http://web.archive.org/web/20100904140711/http://pointedears.de/scripts/test/mime-types/" rel="noreferrer">Test Case: Support for Scripting Media Types</a>.</p> <p>One solution is to configure the server if possible, as already recommended. For Apache, this can be as simple as adding the directive</p> <pre><code>AddType text/javascript .js </code></pre> <p>(see the <a href="http://httpd.apache.org/docs/2.2/mod/mod_mime.html#addtype" rel="noreferrer">Apache HTTP Server documentation</a> for details).</p> <p>But if the client-side script resource is generated by a server-side application, like PHP, then it is necessary to set the <code>Content-Type</code> header field value explicitly, as the default is likely <code>text/html</code>:</p> <pre><code>&lt;?php header('Content-Type: text/javascript; charset=UTF-8'); // ... ?&gt; </code></pre> <p>(That and similar statements must come before any other output – see the <a href="http://php.net/header" rel="noreferrer">PHP manual</a> –, else the HTTP message body is considered to have begun already and it is too late to send more header fields.)</p> <p>Server-side generation can happen easily to a client-side script resource even if you have plain .js files on the server, if comments are removed from them as they are served, if they are all packed into one large response (to reduce the number of requests, which can be more efficient), or they are minimized by the server-side application in any other way.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload