I've the following code:
getTrainPlanDetail: function(id){
var df = new $.Deferred();
$.post( config.api, addJSONHeaders("detail_fiche_entrainement",{"idRequete": id}), function(data){
if (ajaxEval(data)){
df.resolve(data);
} else {
df.fail(data);
}
}, 'json').fail(function(jqXHR, textStatus, errorThrown){
df.fail();
});
return df.promise();
},
after minification it gets converted into:
getTrainPlanDetail: function(a) {
var b = new $.Deferred;
return $.post(config.api, addJSONHeaders("detail_fiche_entrainement", {idRequete: a}), function(a) {
ajaxEval(a) ? b.resolve(a) : b.fail(a)
}, "json").fail(function() {
b.fail()
}), b.promise()
}
Do you notice the problem with the return? I want to return the b.promise(); not the $.post Can someone tell me why is this happening? To me it doesn't make sense.
You are returning b.promise(). The minifier is making use of the comma operator which returns its last operand:
return 1, 2; // returns 2
return 1, 2, 3; // returns 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With