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
4

2 回答 2

4

如输出所示,我的字符集是 UTF8 而不是 UTF-8。问题是在服务器端。

于 2012-08-02T11:48:58.927 回答
0

这可能要问很多,但是您可以尝试将您的完整$.ajax通话替换为$.getJSON吗?浏览器执行起来会更加简单和容易,因为您的问题可能出在您为 ajax 调用所做的众多设置和配置之一中。

尽可能简单:

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

如果您需要检查 getJSON,请在此处查看

于 2012-08-02T10:02:59.207 回答