jquery - How to load ISO-8859-1 content via AJAX in jQueryMobile 1.3.1 with correct character encoding? -
i have got php script (cms) generates iso-8859-1 content (in background there database latin1 data). visualize data on mobile devices use jquery mobile 1.3.1. in general there no problem character encoding if use correct meta tag in html:
<meta charset="iso-8859-1" />
however jquery mobile has got default setting:
$.mobile.ajaxenabled = true;
so jquery mobile automatically handle link clicks , form submissions through ajax, when possible.
this smart feature, destroys special characters german umlaute , nasty characters: �
the problem jquery mobile 1.3.1 uses on default utf-8 on ajax requests. there different solutions solve problem:
disable ajax specific links, redirect content special characters:
data-ajax="false"
turn off ajax preloading feature:
$.mobile.ajaxenabled = false;
follow recommendation , manually set correct content type , override mime type:
$.ajaxsetup({ contenttype: 'application/x-www-form-urlencoded; charset=iso-8859-1', beforesend: function(jqxhr) { jqxhr.overridemimetype('application/x-www-form-urlencoded; charset=iso-8859-1'); } });
the last solution did work me.
Comments
Post a Comment