Hi all,
what’s the difference between this
1)
var ready = $.Deferred();
window.FBReady = ready.promise();
window.fbAsyncInit = function() {
FB.init({
appId : window.FB_APP_ID, // App ID
channelUrl : '//' + window.location.host + '/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
frictionlessRequests: true
});
// Make sure the user is logged in and redirect if needed
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
ready.resolve(response);
} else {
ready.reject(response);
}
});
};
window.FBReady.done(function(response){
//do something
}).fail(function(response){
//do something
});
and
2)
var ready = $.Deferred();
window.fbAsyncInit = function() {
FB.init({
appId : window.FB_APP_ID, // App ID
channelUrl : '//' + window.location.host + '/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
frictionlessRequests: true
});
// Make sure the user is logged in and redirect if needed
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
ready.resolve(response);
} else {
ready.reject(response);
}
});
};
ready.done(function(response){
//do something
}).fail(function(response){
//do something
});
imo the promise is not necessary
but I’ve a doubt ^^
Can you enlight me, please ?