因为升级从jQuery的1.4到1.5后的数据被重写重写、数据、jQuery

2023-09-10 17:58:28 作者:苦口。

由于从1.4升级到jQuery的的最新版本,我的ajax的职位不再允许? (双问号)。相反,它们将被替换为类似jQuery15206629880418804291_1302038490086

Since upgrading to the lastest version of jQuery from 1.4, my ajax posts no longer allow ?? (double question marks). Instead they are replaced with something like jQuery15206629880418804291_1302038490086

用Firebug,我可以看到一个帖子发送以下数据:

Using Firebug, I can see the following data sent in a post:

$.ajaxSetup({
            type: 'POST',
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            global: false
        });

this._xhrM = $.ajax({
            url: '/services/chatroomservice.asmx/SendReceive',
            data: '{"R": "??"}',
        success: function (results) {}
};

通过网络发送的:

Sent over the wire as:

{"R": "jQuery15206629880418804291_1302038490086"}

我已经尝试设置了传统的以真实和过程数据为假,两人都没有效果。

I have tried setting the traditional to true and processData to false, both had no effect.

推荐答案

设置 JSONP 选项。按照文档应该prevent 从jQuery的1.5被扩大到一个函数+。

Set the jsonp option to false. According to the docs that should prevent ? from being expanded to a function in jQuery 1.5+.

this._xhrM = $.ajax({
            url: '/services/chatroomservice.asmx/SendReceive',
            data: '{"R": "??"}',
            jsonp: false,
            success: function (results) {}
});