Search This Blog

Monday, December 14, 2009

Photoshop Wings

Sunday, December 6, 2009

Jquery: ajax post and encoding

Works fine in my side.. Thanks to Rodrigo Asensio.


I have a better solution now. Both post and get works PERFECTLY. I'm working over tomcat who by default handle ISO 8859 stuff.

Web page properties:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
charset of the webpage inside the head.
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
Now, all my parameteres are escaped with escape function, I provided this solution before.
(function($) {$.fn.escape = function() {
return escape(this.val());};})(jQuery);
Now, when sending the ajax request I set the contentType to this:
contentType : "application/x-www-form-urlencoded; charset=iso-8859-1"
And finally , when receiving the parameters at the servlet or any receiver I get a decoded parameter using this.
    public String getHttpParameter(String name) throws Exception {
String value = this.getHttpRequest().getParameter(name);
return value == null || value.isEmpty() ? value : URLDecoder.decode(value,"ISO-8859-1");
POST and GET works perfectly in IE 7 and 8 , SAFARI, CHROME and FIREFOX.