Firefox 14.0.1 returns an error while reading a JSON file sent via AJAX

Firefox 13.0.1 and IE7 + work fine with the JSON file on the server. However, FF14 returns this error message generated by the console when I open the JSON (stored online) file in the browser:

The character encoding of the text document has not been declared. The document will be displayed with garbled text in some configuration browsers if the document contains characters from outside US-ASCII. The character encoding of the file must be declared in the transmission protocol or file, use the byte order mark as the encoding signature.

http://lifelearning.x10.mx/test/php_slides.js.

And when you visit this website (my testing website) http://lifelearning.x10.mx/test/php_slides.html (you can view the codes there) and scroll the mouse within the div (surrounded by a black border), texts do not come out in anticipation (which is otherwise done in any browsers listed above, except for FF14).

I would like to ask how can I declare a plain text character encoding as requested by the FF14 web console.

+4
source share
2 answers

The content type and character encoding can be set using the HTTP header. You probably need a heading:

Content-type: application/json; charset=UTF-8 

If you are serving json data with php, you can add this header with the header() command. If you are using apache, you can use the .htaccess file with these lines:

 AddType application/json .json AddCharset UTF-8 .json 
+9
source

I got this error when I included a php script in a PHP script. When I put the include tags in the script tags, the error stopped.

0
source

All Articles