I've this piece of code, and i built the other function only to try another way to do that.
var cookie_val = "";
function getCookie() {
$.when($.ajax("../handlers/users/get_user.ashx")).then(function (data, textStatus, jqXHR) {
$.when(getCookieValue(data)).then(function () {
cookie_val = $.cookie("default_value:" + cookie_val);
});
});
return cookie_val;
}
function getCookieValue(data) {
cookie_val = data;
}
this works, but only if i execute the function twice, how can i do to make this work at the first call?