我在远程位置托管了 Ejabberd 服务器。我正在尝试使用 Strope.js 注册插件注册新帐户,但我找不到为什么这不起作用。下面是我写的代码
var connection = new Strophe.Connection("http://ip-address:5222/http-bind");
var callback = function (status) {
alert(Strophe.Status.REGISTER); // Returning me 10
if (status === Strophe.Status.REGISTER) {
alert("Entered");
connection.register.fields.username = "hello";
connection.register.fields.password = "hello";
connection.register.submit();
} else if (status === Strophe.Status.REGISTERED) {
alert("registered!");
connection.authenticate();
} else if (status === Strophe.Status.CONNECTED) {
alert("logged in!");
} else {
// Sometimes execution entering into this block.
document.body.innerHTML = (JSON.stringify(status));
}
};
connection.register.connect("localhost", callback);
要添加到此的任何额外代码或我必须做的任何修复才能使此工作正常进行。请帮我解决这个问题。 Strope.js 文档很糟糕。
最佳答案
在strope.register.js中,转到第215行并按照以下代码进行更改。
/*if (register.length === 0) {
that._changeConnectStatus(Strophe.Status.REGIFAIL, null);
return;
} else */
this.enabled = true;
尝试上面的一个。
关于javascript - Strope.js 注册插件不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21157216/