When I alert the returned value from the jsonServerResponse function, its value is undefined - despite JSON being returned from the process.php page.
function jsonServerResponse(operation, JSOoptionalData) {
JSOoptionalData = (typeof JSOoptionalData == "undefined") ? 'defaultValue' : JSOoptionalData
var jqxhr = $.ajax({
type: "POST",
url: "process.php",
data: "apicommand=" + JSOoptionalData,
success: function (json) {
return jQuery.parseJSON(json);
}
});
}
alert("Response as JS Object: "+jsonServerResponse("operation"));
I know that the problem is that the alert function made before the asynchronous request is complete, but I am unsure how to fix this problem. Any advice is really appreciated :)