我如何獲得從jquery ajax調用返回的數據。 $ .ajax()之外。
//Reloads the inital page
function jobexist(jobname)
{
var dataString = 'jobname=' + jobname;
var found = false;
$.ajax(
{
type: 'POST',
url: "/genode/jobs/jobexist.m",
data: dataString,
dataType: 'json',
success: function(data)
{
alert("Passed");
if(data.result == 0)
{
found = true;
}else{
found = false;
}
},
error: function(data)
{
alert("Login Failed");
return -1; //alert(data);
}
});
if(found == true)
{
alert("found!")'
return true;
}else{
alert("not found!");
return false;
}
}
if(!jobexist(jobname))
{
$("#jobname_error").text("This jobname already exist.");
$("#jobname_error").show();
return false;
}