Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery Ajax doesn't work at Internet Explorer

When I use jQuery ajax put at Internet Explorer 9, I am getting data at response body however it doesn't pass into success function. How can I make it work?

example:

...
    $.ajax({
        async : false,
        type: 'PUT',
        contentType: 'application/json',
        url: updateUrl,
        data: JSON.stringify(model),
        dataType: 'json',
        success: function(data) {
            console.log("Here!");//it comes here
            console.log(data);//it logs undefine at ie, firefox and etc is logging data
            r = resultResponse(data);
        },
        error: function(data) {
            try {
                r = error($.parseJSON(data.responseText));
            } catch (err) {
                //Handle error
            }
        }
    });
...

I debugged network and see that response body is:

{"message":"Connection is successful","status":"success"}

However data is undefined at success function at Internet explorer.

Any ideas?

PS 1: It is weird that when I send data from server without setting content type for response header it works?

PS 2: My response header as follows:

Key Value
Response    HTTP/1.1 200 OK
Server  Apache-Coyote/1.1
Content-Type    application/json;charset=UTF8
Transfer-Encoding   chunked
Date    Thu, 02 Aug 2012 15:50:44 GMT
like image 858
kamaci Avatar asked Oct 07 '22 01:10

kamaci


1 Answers

As seen at output my charset was UTF8 instead of UTF-8. The problem was that at server side.

like image 64
kamaci Avatar answered Oct 13 '22 09:10

kamaci