jQuery Ajax无法在IE上远程工作 [英] jQuery ajax not working remotely on IE

查看:85
本文介绍了jQuery Ajax无法在IE上远程工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在客户端上有一些代码,该代码使用$ .ajax()调用ashx处理程序,并期望来自服务器的json数据.当我在本地Web服务器上运行应用程序时,在FF,IE 6、7、8上一切正常.但是,当我将应用程序部署到远程测试服务器时,IE停止工作($ .ajax返回parsererror),而FF继续按预期工作.

I have some code on the client that calls an ashx handler using $.ajax() and expects json data from the server. Everything works fine on FF, IE 6,7,8 when I run the application on a local webserver. However, when I deploy the application to a remote test server, IEs stopped working ($.ajax returns a parsererror), while FF continues to work as expected.

我首先想到的是,我的json对象必须具有IE讨厌的试用逗号,但这不是问题,因为没有试用逗号.然后,我尝试将内容类型从app/json更改为tex/plain,仍然是相同的错误.

My first thought was that my json object must have a trialing comma which IEs hate, but that wasn't the issue as there were no trialing commas. Then, I tried changing various things like the content types from app/json to tex/plain, still the same error.

令我感到奇怪的是,如果我启动小提琴手,则IE将可以远程运行,否则,我将遇到parsererror.

Something that I found odd is that if I fire up fiddler, then IEs will work remotely, otherwise, I get the parsererror.

有人曾经经历过类似的事情吗?谢谢.

Has anyone experienced something like this before? Thanks.

$.ajax({
        type: "GET",
        url: "handlers/GetAsyncResults.ashx",
        contentType: "application/json; charset=utf-8",
        data: {'from': dateFrom, 'to': dateTo, 'accountId' : aId, 'page': currentPage, 'sortField' : sortField, 'sortDirection' : sortDirection},
        dataType: "json",
        success: function(data) { GetAsyncResultsEnd(data); },
        error: function(x, y, z) { GetAsyncResultsErrorHandler(x, y, z); }
    });

添加了代码段.

推荐答案

已排序.谢谢.

在服务器端,我们调用context.Response.Write('我们的json数据')之后,再调用context.Response.Flush()和context.Response.Close().删除.Flush()和.Close()之后,所有内容再次开始工作.但是我仍然无法解释为什么它适用于Firefox,而不适用于IE,也无法解释Fiddler是如何神奇地使其适用于IE的.

On the server end, after we called context.Response.Write('Our json data'), we then call context.Response.Flush() and context.Response.Close(). After we removed the .Flush() and .Close(), everything started working again. But I still can't explain why it's working for firefox and not IE, nor how fiddler magically made it works for IE.

谢谢.

这篇关于jQuery Ajax无法在IE上远程工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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