Returning from a nested function in javascript
问题 I'm trying to make a function that uses jquery's ajaxfunction to get some info from my ajax.php file. code: function ajaxIt(dataLine){ $.ajax({ type: "POST", url: "ajax.php", data: "ajax=true&"+dataLine, success: function(msg){ console.log("[AjaxIt]: "+dataLine+" returned "+msg); return msg; } }); } if(ajaxIt("action=loggedIn")=="1"){ console.log("Logged In"); loggedIn=true; initiate2(); } The problem is that I can't get the success function to return all the way to the ajaxIt function. Could