strophe.flxhr.js - TypeError: this.func.prependArg is not a function

strophe.flxhr.js - TypeError: this.func.prependArg is not a function

strophe.flxhr.js

/* flXHR plugin
**
** This plugin implements cross-domain XmlHttpRequests via an invisible
** Flash plugin.
**
** In order for this to work, the BOSH service *must* serve a
** crossdomain.xml file that allows the client access.
**
** flXHR.js should be loaded before this plugin.
*/

Strophe.addConnectionPlugin('flxhr', {
    init: function () {
        // replace Strophe.Request._newXHR with new flXHR version
        // if flXHR is detected
        if (flensed && flensed.flXHR) {
            Strophe.Request.prototype._newXHR = function () {
                var xhr = new flensed.flXHR({
                    autoUpdatePlayer: true,
                    instancePooling: true,
                    noCacheHeader: false});
                xhr.onreadystatechange = this.func.prependArg(this);

                return xhr;
            };
        } else {
            Strophe.error("flXHR plugin loaded, but flXHR not found." +
                          "  Falling back to native XHR implementation.");
        }
    }
});

这是一本书提供的代码,我正在尝试使用 JavaScript 和 jQuery 学习 XMPP 编程。它还使用 strophe.jsflXHR.jsstrophe.flxhr.js 在主应用程序中用作脚本文件。但是当 运行 在我的 FireFox 浏览器中运行该应用程序时,Web 控制台给我错误 TypeError: this.func.prependArg is not a function。我也在使用 WebStorm IDE,它显示 Unresolved function or method prependArg()。但是按照书上的说法,这个应该运行。我做错了什么?

请帮忙。谢谢。

显然,strophe.flxhr.js 文件有问题。这是一个非常旧的版本(6 岁)。 github here 中有一个新版本。 代码略有更改,并且可以正常工作。 Web 控制台不会抛出任何错误。这是新代码:

strophe.flxhr.js:

/* flXHR plugin
**
** This plugin implements cross-domain XmlHttpRequests via an invisible
** Flash plugin.
**
** In order for this to work, the BOSH service *must* serve a
** crossdomain.xml file that allows the client access.
**
** flXHR.js should be loaded before this plugin.
*/

Strophe.addConnectionPlugin('flxhr', {
    init: function (conn) {
        // replace Strophe.Request._newXHR with new flXHR version
        // if flXHR is detected
        if (flensed && flensed.flXHR) {
            Strophe.Request.prototype._newXHR = function () {
                var xhr = new flensed.flXHR({
                    autoUpdatePlayer: true,
                    instancePooling: true,
                    noCacheHeader: false,
                    onerror: function () {
                        conn._changeConnectStatus(Strophe.Status.CONNFAIL,
                                                  "flXHR connection error");
                        conn._onDisconnectTimeout();
                    }});
                xhr.onreadystatechange = this.func.bind(null, this);

                return xhr;
            };
        } else {
            Strophe.error("flXHR plugin loaded, but flXHR not found." +
                          "  Falling back to native XHR implementation.");
        }
    }
});

EDIT: From the developer of this script, Jack Moffitt: "This code no longer works. strophe.flxhr.js just makes some testing easier as it relaxes the CORS requirement by using Flash instead. Most things support CORS natively now, so it is probably not needed anyway. It doesn't provide any APIs or anything that are needed by the example code; it's purely an alternate implementation of XMLHttpRequest. If you can make the newer version work, then use it.". Here is the conversation.