function getCChatStatus() {
jQuery.ajax({
type: "POST",
url: "index.php?page=CChatAction",
data: { action: "getStatus" }
}).done(function(msg) {
var cChatStatus = jQuery.parseJSON(msg);
return cChatStatus;
});
}
function CChatOptions() {
var test = getCChatStatus();
alert(test);
}
is returning “test is undefined”.
How to solve this issue? I already tried async: false.
Thanks
If you use asynchronous functions like jQuery.ajax, you will have to use callback functions to evaluate the results.
Thus, your getter has to be asynchronous:
And your test will have to look like: