HighDots Forums  

load() and utf-8 encoding, nothing seems to work...

jQuery jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. jQuery is designed to change the way that you write JavaScript.


Discuss load() and utf-8 encoding, nothing seems to work... in the jQuery forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ximo wallas
 
Posts: n/a

Default load() and utf-8 encoding, nothing seems to work... - 11-04-2009 , 12:59 PM






I've been googling around but found no answer that works for me.
I'm loading some content from a PHP script using the load() function inside an html document that already has the utf-8 encoding meta tag. I suposed that the rule at the head of the container document will affect all loaded contents, but it doesn't.
The PHP I'm loading is using a switch to serve different contents, for every case I have open php tags like this:

case '1':
?>
Here comes the choosen HTML contents
<?
break

In my PHP I have also placed a header to indicate the content is utf-8:
header ('Content-type: text/html; charset=utf-8');
But maybe just because the final content is out of php tags maybe it is not affecting the content...
I have also tried setting the AJAX defaults:

*** $.ajaxSetup({
******* scriptCharset: "utf-8" ,
******* contentType: "text/html; charset=utf-8"
*** });
But not even like that...
How can I fix that?

Reply With Quote
  #2  
Old   
Nick Fitzsimons
 
Posts: n/a

Default Re: [jQuery] load() and utf-8 encoding, nothing seems to work... - 11-05-2009 , 07:42 AM






2009/11/4 ximo wallas <igguana26 (AT) yahoo (DOT) com>
Quote:
I've been googling around but found no answer that works for me.
I'm loading some content from a PHP script using the load() function inside an html document
that already has the utf-8 encoding meta tag. I suposed that the rule at the head of the container
document will affect all loaded contents, but it doesn't.
Just because your HTML document has a meta tag declaring that it's
UTF-8 doesn't necessarily make it so: the meta element is only used as
a fallback if the server hasn't specified the encoding in its HTTP
headers.

If you load your page in Firefox with Firebug's Net panel enabled,
you'll be able to see if the server is specifying an encoding which is
taking precedence: a response header like

Content-Type: text/html; charset=ISO-8859-1

would mean that the browser will treat your document as ISO-8859-1, no
matter what the meta tag says (in fact, the browser will never even
look at the meta tag if the header is present).

If, as it sounds from your description, the HTML is in a static file
rather than being dynamically generated, then bear in mind that it's
also necessary for that HTML document to actually _be_ UTF-8: in other
words, it should have been saved as UTF-8 by whatever editor was used
to create it.

Regards,

Nick.
--
Nick Fitzsimons
http://www.nickfitz.co.uk/

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.