jQuery的阿贾克斯不会在Internet Explorer中工作 [英] Jquery Ajax doesn't work at Internet Explorer

查看:150
本文介绍了jQuery的阿贾克斯不会在Internet Explorer中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用jQuery AJAX投入在Internet Explorer 9中,我得到的数据,在响应主体但它并没有传递到成功的功能。我怎样才能使它工作?

例如:

  ...
    $阿贾克斯({
        异步:假的,
        键入:把',
        的contentType:应用/ JSON的,
        网址:器updateURL,
        数据:JSON.stringify(模型),
        数据类型:JSON,
        成功:功能(数据){
            的console.log(在这里!); //说到这里
            执行console.log(数据); //它在如记录UNDEFINE,火狐等正在记录数据
            R = resultResponse(数据);
        },
        错误:功能(数据){
            尝试 {
                R =错误($ parseJSON(data.responseText)。);
            }赶上(错误){
                //处理错误
            }
        }
    });
...
 

我调试网络,看到身体的反应是:

  {消息:连接成功,状态:成功}
 

不过数据是不确定的,在成功的功能在IE浏览器。

任何想法?

PS 1:这是奇怪的,当我从服务器发送数据,而无需将内容类型响应头部它的工作原理

PS 2:我的响应头如下:

 核心价值
响应HTTP / 1.1 200 OK
服务器Apache的狼/ 1.1
内容类型的应用程序/ JSON的;字符集= UTF8
传输编码分块
日期星期四,2012年8月2日15点50分44秒GMT
 

解决方案

可以看出,在输出我的字符集是UTF8,而不是UTF-8。问题是,在服务器侧

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

解决方案

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

这篇关于jQuery的阿贾克斯不会在Internet Explorer中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆