var
data = getCouponData(code);
console.log(data); //3
function getCouponData(code) {
var result = false;
if (isValidCoupon(code)) {
$.post('/coupons/check', {code: code}, function (data) {
result = data;
console.log(result);//1
}, "json");
}
console.log(result);//2
return result;
}
false
false
Object {coupon_id: 1, active: 1, created_at: "2015-07-29 20:30:27"}