I live in Norway, and here our alphabet is 29 characters long because of our 3 special characters ÆØÅ. I can’t begin to describe how much pain these 3 characters have caused for developers in our country. This is why keeping the same encoding in all files the same is so important, I stick with UTF-8 because of it’s support for special characters.

So today a client contacted me, and told me one of the forms didn’t work with ÆØÅ. This was a form on a complex page I had worked quite a bit on, so I knew there shouldn’t be problems on it. So I went to the page and checked it out, no problems found, hmm.. Ok, let us try with Internet Explorer then, since I usually use Firefox. Now I also got the problem my client described.

Special characters doesn't show as expected in IE

Ok, so now I had found the problem, at least I thought I had. So I went through the code and checked that all files were UTF-8 and found that the JS file wasn’t, this page uses a bit of Jquery and sends the data with AJAX. Yes! I fixed it.. I thought. but no-no.. Problem still there.

Now I started doing some various testing on the page seeing if the values were what they should be. Everything seemed to be working both in IE and FireFox, so I started looking at the Network traffic and saw that the AJAX requests were sent as GET and IE couldn’t handle the specialcharacters in the URL. When I changed the AJAX request type to POST it worked.

 

$.ajax({
	type: 'POST',
	url: "/path/to/ajax/handleajax.php",
	data: "action=save"+field+"&id="+artistId+"&title="+title,
	success: function(data) {
		closeForm(field);
		update(field);
	}
});

What fixed all this trouble was the line I added at line 2 above type: ‘POST’,