PDA

View Full Version : Ajax.request - Umlaut problem



hentobali
6 Apr 2010, 5:20 AM
Hello,


we have now problem with the germany "umlaut" (,,), if we used

Ext.Ajax.request({
url: furl,
success: displayResult
});


we become then one wrong code for all umlauts, so that no differences.
pls pay attention, all right mit HTML (encoding...), only per AJAX didn't do right.


can anyone suggest us?

Thanks a lot!

Condor
6 Apr 2010, 5:56 AM
I assume you are using UTF-8 to encode the text with umlauts?

1. Does your server return the data with Content-type: <mimetype>; charset=UTF-8?
2. Is the HTML page itself in UTF-8 (otherwise you still can't display umlauts)?

Animal
6 Apr 2010, 6:32 AM
I assume you are using UTF-8 to encode the text with umlauts?

2. Is the HTML page itself in UTF-8 (otherwise you still can't display umlauts)?

This is not the case.

Once a page's bytes have been read off the wire, and decoded into Characters using whatever decoding was specified in the packet's Content-Type header, then it's all just Unicode.

You cannot initially send umlauts (or any character with diacritical marks) in the initial page which uses ISO-8859-1

But if, subsequently, you make an Ajax request, and that receives eg "strupvej 53", then it will display fine.

What matters is that the "charset" specified in the Content-Type header actually matches the encoding that was used to create the byte stream.

hentobali
6 Apr 2010, 6:52 AM
hi,


in HTML already defined:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">


where should still define?


Thanks

Condor
6 Apr 2010, 6:55 AM
You also need to specify the Content-type in the header of your server response.

parsbin
6 Apr 2011, 11:26 PM
i have same problem but just in IE.
Ext,Ajax.Request has worked perfect but when the user uses IE, the unicode characters not send healthy.
i`v uses charset in my html page.
my code is:


handler: function(){
if(fp.getForm().isValid()){
var sb = Ext.getCmp('form-statusbar');
fp.getEl().mask();

var val_name = Ext.getCmp('name').getValue();
var val_description = Ext.getCmp('description').getValue();

var url = 'add_user.php?create=user'
+'&name='+val_name
+'&description='+val_description;

Ext.Ajax.request({
url:url,
scriptTag: true,
success: function(result,request){
sb.setStatus({
text:status_chap,
iconCls:icon_show,
clear: true
});
fp.getEl().unmask();

}

});
}
}

parsbin
12 Apr 2011, 11:39 PM
solved!
i`v use:



var enc=encodeURIComponent||escape;


var val_name = enc(Ext.getCmp('name').getValue());
var val_family = enc(Ext.getCmp('family').getValue());
.
.
.