revision-diff.txt (1.9 KB)
Hi, we have experienced some issues with non-ascii characters in ajax requests in the sense that the request parameters are not decoded properly on the server side, with different behavior over browsers and servlet containers. This is a potential source for trouble since the content-encoding/type header fields are not propertly respected in either browsers or servers, also because javascript uses UTF-8 as default encoding, HTTP uses ISO-8859 while java uses a modified UTF-8 internally. After some digging it turned out that the get and getJSON jQuery’s ajax functions do not send any content-type header field at all, and that the post function sets it to ‘application/x-www-form-urlencoded’. Now the only reliable way I found to transmit non-ascii characters as query parameters was to send all requests as post and set the content-type header to ‘application/x-www-form-urlencoded;charset=utf-8’. Both tomcat and jetty will then decode eg. norwegian and vietnamese properly. I have added some convenience methods for working more easily with this here.
···
On Mon, May 23, 2011 at 7:45 PM, noreply@launchpad.net wrote:
revno: 3712
committer: Lars Helge Overland larshelge@gmail.com
branch nick: dhis2
timestamp: Mon 2011-05-23 19:44:10 +0200
message:
Added ajax utility jquery extension
added:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.utils.js
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm
–
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== added file ‘dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.utils.js’
— dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.utils.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.utils.js 2011-05-23 17:44:10 +0000
@@ -0,0 +1,10 @@
+jQuery.extend( {
postJSON: function( url, data, success ) {
$.ajax( { url:url, data:data, success:success, type:'post', dataType:'json', contentType:'application/x-www-form-urlencoded;charset=utf-8' } );
},
postUTF8: function( url, data, success ) {
$.ajax( { url:url, data:data, success:success, type:'post', contentType:'application/x-www-form-urlencoded;charset=utf-8' } );
}
+} );
\ No newline at end of file
=== modified file ‘dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm’
— dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm 2011-05-19 11:57:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm 2011-05-23 17:44:10 +0000
@@ -26,6 +26,7 @@
<script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/jquery.tablesorter.min.js"></script> <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/jquery.upload-1.0.2.min.js"></script> <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/jquery.utils.js"></script> <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/ui/jquery-ui-1.8.12.custom.min.js"></script> <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/ui/jquery.block.js"></script> <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/ui/ui.thickbox.min.js"></script>
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help : https://help.launchpad.net/ListHelp