1

I have got a PHP script (CMS) which generates ISO-8859-1 content (in the background there is also a database with Latin1 data). To visualize the data on mobile devices I use jQuery Mobile 1.3.1. In general there is no problem with character encoding if you use the correct meta tag in your HTML:

<meta charset="iso-8859-1" />

However jQuery Mobile has got this default setting:

$.mobile.ajaxEnabled = true;

So jQuery Mobile will automatically handle link clicks and form submissions through Ajax, when possible.

This is a very smart feature, but it destroys some special characters like german umlaute and you get this nasty characters: �

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
malisokan
  • 5,362
  • 2
  • 20
  • 19

1 Answers1

8

The problem is that jQuery Mobile 1.3.1 uses on default UTF-8 on ajax requests. There are different solutions to solve the problem:

  1. Disable Ajax for specific links, which redirect to content with special characters:

    data-ajax="false"
    
  2. Turn off completely the ajax preloading feature:

    $.mobile.ajaxEnabled = false;
    
  3. Follow this recommendation and manually set the correct content type and override the 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 for me.

Community
  • 1
  • 1
malisokan
  • 5,362
  • 2
  • 20
  • 19
  • An old thread but it saved my day! Two days of dealing with this problem and the answer I found was downvoted by someone! I would upvote twice if I could! Thanks you!!! – cameron Sep 23 '15 at 14:25