CGridView ajax update changes character encoding

Hi All. I’m developing an app that use a ms-sql backend that is in iso-8851-9 charset and so I configured accordingly my Application->charset and html pages’ headers.

Normal page request works correctly and all is displayed correctly, but if I refresh a grid through ajax (by sorting or paging it) the dreaded black boxes come out. This means that the charset has been automatically "upgraded" to utf-8.

I suppose this is to blame on Jquery ajax functions, but how can I fix it without removing ajax functionality?

Thanks for any hint,

Fabrizio

Check the documentation for the jQuery.ajax() method - http://api.jquery.com/jQuery.ajax/

The interesting part is:

Thanks, you helped me confirming what I suspected. However, my problem is not server side - the request gets easily processed even if it’s in UTF-8, it’s the response that must be displayed accordingly to the right charset. I will experiment with jquery ajax options to see if I can force it.

bye!

Apparently, all that is needed to force correct charset in ajax responses is outputting a proper header i.e.


<?php header('Content-Type: text/html; charset=ISO-8859-15'); ?>

I already had a meta header in my default layout but it’s not enough. Probably I could obtain the same effect with a server configuration, but that’s out of my reach so I’ll live with that.

Bye!