Search This Blog
Monday, December 14, 2009
Sunday, December 6, 2009
Jquery: ajax post and encoding
Works fine in my side.. Thanks to Rodrigo Asensio.
From http://stackoverflow.com/questions/965150/jquery-ajax-post-and-encoding/1229012#1229012
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:
From http://stackoverflow.com/questions/965150/jquery-ajax-post-and-encoding/1229012#1229012
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" "http://www.w3.org/TR/html4/loose.dtd">
charset of the webpage inside the head.Now, all my parameteres are escaped with escape function, I provided this solution before.<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
(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.POST and GET works perfectly in IE 7 and 8 , SAFARI, CHROME and FIREFOX.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");
}
Subscribe to:
Posts (Atom)