我有一个函数,它执行一些task.inside函数,我有一个ajax调用。如果从ajaxcall获得的响应为真,则该函数应该继续执行其余的任务。否则它应该停止在该点本身。 但上面说的事情没有发生,而是函数独立于ajax调用执行。 请帮我在这ajax函数内呼叫
function f1(id)
{
var test= id
var url="[email protected]"=+id;
var ajax=new Ajaxrequest(url,validatecallback);
ajax.doGet();
if(id==true){
return;
}
........(some code which has to carried out after the ajax call)
}
function validatecallback
{
this function gets the response for the above mentioned ajaxcall
we are setting a global variable(i.e id) here so that we can use that we can retrieve that in function f1
}
可能重复[如何从Ajax调用返回响应?](http://stackoverflow.com/questions/14220321/how-to-return-the-响应从-AN-Ajax的呼叫) – Bergi 2014-10-28 14:46:28