Fix jQuery.ajax() errors in IE

Fix jQuery.ajax() errors in IE

Hi all,

I thought it might be worth spreading the word about the solution of a strange problem in IE:

All my jQuery.ajax() requests were kind of ignored in IE and didn't return any data. After debugging them I got a "parseerror" and a strange "Error c00ce56e" in my IE. This error code is related to an encoding error if using the UTF-8 charset.

If you got a similar problem with your AJAX requests not returning any data, try out the following code to see if you also get the c00ce56e error code:
  1. $(document).ready(function() {   
        $.ajax
         ({
            dataType: "html",
            error:function(xhr, status, errorThrown) {
                alert(errorThrown+'\n'+status+'\n'+xhr.statusText);
            },
            success:function(callback) {
                alert("I'm a success");
            }
        });   
    });













If so, the problem is probably related to a missing or mismatched server default_charset (if running PHP).
So the solution is pretty easy: either ask your webhost to change it to your website's charset (was UTF-8 for me), or do it on your own by adding the following line to an .htaccess file in your website root:
  1. # pass the default character set
    AddDefaultCharset utf-8



That's it!

After two days of debugging, my AJAX requests finally work in IE!

I hope that this post can be useful for somebody else, too.

Cheers,
Eric