jQuery AJAX Character Encoding Problem
Posted
by Salty
on Stack Overflow
See other posts from Stack Overflow
or by Salty
Published on 2009-02-16T14:30:49Z
Indexed on
2010/03/21
23:01 UTC
Read the original article
Hit count: 590
Hi everyone,
I'm currently coding a French website. There's a schedule page, where a link on the side can be used to load another day's schedule.
http://aquate.us/film/horaire.html
(At the moment, only the links for November 13th and November 14th work)
Here's the JS I'm using to do this:
<script type="text/javascript">
function load(y) {
$.get(y,function(d) {
$("#replace").html(d);
mod();
});
}
function mod() {
$("#dates a").click(function() {
y = $(this).attr("href");
load(y);
return false;
});
}
mod();
</script>
The actual AJAX works like a charm. My problem lies with the response to the request.
Because it is a French website, there are many accented letters. I'm using the ISO-8859-15 charset for that very reason. However, in the response to my AJAX request, the accents are becoming ?'s because the character encoding seems to be changed back to UTF-8.
How do I avoid this? I've already tried adding some PHP at the top of the requested documents to set the character set:
<?php header('Content-Type: text/html; charset=ISO-8859-15'); ?>
But that doesn't seem to work either. Any thoughts?
Also, while any of you are looking here...why does the rightmost column seem to become smaller when a new page is loaded, causing the table to distort and each <li>
within the <td>
to wrap to the next line?
Cheers
© Stack Overflow or respective owner