AJAX GET won't work in Internet Explorer
Hey everyone,
I have come a cross a bit of a problem. I have an AJAX function that sends a GET with 2 parameters (postalCode and streetName) and recieves a json array as response.
The problem is: It's a danish site. In the danish alfabet we have letters like "æ, ø, å". Therefore we're forced to use iso-8859-1 as charset. It function it self works perfectly in Firefox, Opera and Safari. And the funny thing is, that it also works in Internet Explorer - until the streetName contains either of the three before mentioned letters.
I've tried to change the default AJAX call with ajaxSetup() and I pretty much drained Google for information in such a way, that I can't come up with other search strings.
Here is my code:
- // Figure out which district the postalCode belongs to
- $('#collectorPostalCode').blur(function() {
- var postalCode = $(this).val();
- var streetName = $('#collectorAddressStreet').val();
-
- $.ajax({
- type: 'get',
- url: '/ajax/findDistrict.php',
- data: 'postalCode=' + postalCode + '&streetName=' + streetName,
- dataType: 'json',
- success: function(data) {
- alert(data);
- }
- });
- });
Like I said it works perfectly - even in IE - until either of the danish letters "æ, ø, å" is within the streetName, then data is just returned as null. In every other request it returns perfectly with an object.
My own theory is that IE can't handle the letters since it's being sented as GET. Which is also the reason you can't buy domain names with either of those letters. But that's just a theory.
I'm sincerly hoping that someone can help me. Or even have an idea for a workaround.
In advance, thank you so damn much! :D
Best regards,
Morten / DuGi