MooTools JSONP 请求不适用于无效密码

发布于 2024-08-17 16:03:51 字数 696 浏览 5 评论 0原文

我使用 MooTools 发出 JSONP 请求:

var username = 'hsz';
var password = 'pass';
var req = new Request.JSONP({
    url: 'http://api.blip.pl/profile.json',
    method: 'get',
    headers: {
        'Authorization' : 'Basic ' + Base64.encode(username + ':' + password),
        'Accept'        : 'application/json',
        'Content-Type'  : 'application/json',
        'X-blip-api'    : '0.02'
    },
    onSuccess: function(res){ alert('success'); },
    onFailure: function(res){ alert('failure'); }
}).send();

使用有效的登录名和密码,它可以正常工作(提醒我成功)。
当我将密码更改为无效值时,它不会执行任何操作。
我不知道为什么它表现得很糟糕。
当我使用 Request.JSON() 时也是如此。 有什么想法吗?

I make a JSONP request using MooTools:

var username = 'hsz';
var password = 'pass';
var req = new Request.JSONP({
    url: 'http://api.blip.pl/profile.json',
    method: 'get',
    headers: {
        'Authorization' : 'Basic ' + Base64.encode(username + ':' + password),
        'Accept'        : 'application/json',
        'Content-Type'  : 'application/json',
        'X-blip-api'    : '0.02'
    },
    onSuccess: function(res){ alert('success'); },
    onFailure: function(res){ alert('failure'); }
}).send();

With valid login and password it works fine (alerts me success).
When I change password to an invalid value it does not do anything.
I do not know why it behaves badly.
Same thing when I use Request.JSON().
Any ideas ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

画尸师 2024-08-24 16:03:51

可能是服务没有响应任何内容,因为它无法验证/授权请求,只是为了在密码或用户 ID 或两者都错误时留下任何黑客!

May be service is not responding with anything whey it cannot authenticate/authorize the request just to leave any hacker if password or user id or both are wrong!

野稚 2024-08-24 16:03:51

我认为 onFailure 只是 Request 类在 XHR 请求中失败时触发的事件。如果您无法进行身份验证,并不意味着它无法触发 Request 实例,只是无法获得预期的结果。

在 1.2.4.x 中,request.jsonp 支持可选日志(实现的控制台包装类日志) - 将 log: true 添加到类选项中,并查看它尝试在 firebug 中引发哪些事件。

另外,您可以将处理程序更改为 onComplete 并插入返回的 json,以根据数据确定其成功程度(与 onSuccess 相反)

i think the onFailure is simply the event fired by the Request class when it fails in the XHR request. if you fail to authenticate it won't not mean it failed to fire the Request instance, just failing to get the expected results.

in 1.2.4.x, request.jsonp supports optional log (implemented console wrapper class log) - add log: true to the class options and see what events it tries to raise in firebug.

also, you can change the handler to onComplete and interpolate the json returned to determine how successful it has been based upon the data (as opposed to onSuccess)

烟若柳尘 2024-08-24 16:03:51

JSONP 类有一个超时属性。默认设置为0并且onFailure不被触发。

我设置了 timeout:1 现在 onFailure 被触发。

At the JSONP class there is a timeout property. By default is set to 0 and onFailure was not triggered.

I set timeout:1 and now onFailure is triggered.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文