Question

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 ?

Was it helpful?

Solution

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!

OTHER TIPS

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)

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top