How to send Unicode Characters, such as German Umlauts, through JQuery AJAX

JQuery gives nonsense when Umlauts are entered.

2 Important things to fix here

  • Set the content type to: application/x-www-form-urlencoded; charset=UTF-8
  • Use POST

Code below to fix this:

$.ajax({
      url:url,
      contentType: "application/x-www-form-urlencoded; charset=UTF-8",
      data:({
            //Parameters
      }),
      type: 'POST',
      success: function(data) {
           //Success code
      },
      error: function(transport) {
            alert('AJAX ERROR: ' + eval(transport));
      }
});
Categories: JavaScript, JQuery
Written on November 21, 2010