views:

208

answers:

1

I have a HTML-page, that's encoded in ISO-8859-1 and a Prototype-AJAX call that's build like this:

new Ajax.Request('api.jsp', {
    method: 'get',
    parameters: {...},
    onSuccess: function(transport) {
        var ajaxResponse = transport.responseJSON;
        alert(ajaxResponse.msg);
    }
});

The api.jsp returns its data in ISO-8859-1. The response contains special characters (German Umlauts) that are not displayed correctly, even if I add a "encoding: ISO-8895-1" to the AJAX-request. Does anyone know how to fix this?

If I call api.jsp in a new browser window separately the special characters are also corrupt. And I can't get any information about the used encoding in the response header. The response header looks like this:

Server  Apache-Coyote/1.1
Content-Type    application/json
Content-Length  208
Date    Thu, 29 Apr 2010 14:40:24 GMT

Notice: Please don't advice the usage of UTF-8. I have to deal with ISO-8859-1.

A: 

Just found the answer myself. Though this is for PHP I'm sure you can find the equivalent for ASP :)

Basically, just include the encoding header on your response page (in your case api.asp), like this:

header("Content-Type: text/html; charset=ISO-8859-1");

Good luck with it :)

//Jannik Olsen

Jannik Olsen
You're right - it was as simple as that, I already found it out. Thanks nevertheless!
acme