I have a js function , after doing some business logic, the javascript function should return some result to another variable.Sample code below
var response="";
function doSomething() {
$.ajax({
url:'action.php',
type: "POST",
data: dataString,
success: function (txtBack) {
if(txtBack==1) {
status=1;
}
});
return status;
}
Here i want to use like
response=doSomething();
I want to assign a return value "status" "var response".But the result is 'undefined'.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…