5

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
kamaci
  • 72,915
  • 69
  • 228
  • 366

2 Answers2

4

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

kamaci
  • 72,915
  • 69
  • 228
  • 366
0

This might be much to ask, but can you try to substitute your full $.ajax call into a $.getJSON? it will be much simpler and easier for the browser to execute, as your problem might be in one of the numerous settings and configurations you made for your ajax call.

keep it as simple as you can:

$.getJSON(updateUrl, JSON.stringify(model), function(data){
    console.log(data);
});

If you need to check up on getJSON, check here

Rodik
  • 4,054
  • 26
  • 49