异步Javascript回调函数 [英] Asynchronous Javascript Callback functions
问题描述
您好,
我在使用ajax编写javascript异步函数时遇到问题,我的问题是我写了3个函数with return boolean。
Hello,
I have an issue in to write javascript asynchronous functions with ajax, my problem is that I have written 3 function with return boolean.
function getname(a,b)
{
.. $ajax here
{
success(data)
{
if (data.resultvalue == true){
return true;
}
else
{
return false;
}
}
}
}
=============================================================
function validate(a)
{
.. $ajax here
{
success(data)
{
if (data.resultvalue == true){
return true;
}
else
{
return false;
}
}
}
}
=============================================================
function checken(a)
{
.. $ajax here
{
success(data)
{
if (data.resultvalue == true){
return true;
}
else
{
return false;
}
}
}
}
=============================================================
function callallfunctions()
{
var aval = document.getelementbyid('myval');
if (getname(aval.value,'abc') == true)
{
if (validate('abc') == true)
{
if (checken('def') == true)
{
return true
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
当ajax处理时,它异步工作并返回false。当我合并一个函数中的所有函数,然后它也异步工作并返回值false而ajax正在处理
Its working asynchronously and return value false while ajax is under processing. When i merge all the functions in one function then its working asynchronously too and return value false while ajax is under processing
推荐答案
ajax这里
{
成功(数据)
{
如果(data.resultvalue == true ){
return true ;
}
其他
{
返回 假跨度>;
}
}
}
}
========================== ===================================
功能验证(a)
{
..
ajax here { success(data) { if (data.resultvalue == true){ return true; } else { return false; } } } } ============================================================= function validate(a) { ..
ajax这里
{
成功(数据)
{
if (data.resultvalue == true ){
返回 true ;
}
其他
{
返回 假跨度>;
}
}
}
}
========================== ===================================
功能 checken(a)
{
..
ajax here { success(data) { if (data.resultvalue == true){ return true; } else { return false; } } } } ============================================================= function checken(a) { ..
ajax here
{
success(data)
{
if (data.resultvalue == true ){
返回 true ;
}
其他
{
返回 假跨度>;
}
}
}
}
========================== ===================================
功能 callallfunctions()
{
var aval = document .getelementbyid (' myval');
if (getname(aval.value,' abc')== true )
{
if (验证(' abc')== true )
{
if (checken(' def')== true )
{
return true
}
else
{
返回 false ;
}
}
else
{
return false ;
}
}
else
{
return false ;
}
}
ajax here { success(data) { if (data.resultvalue == true){ return true; } else { return false; } } } } ============================================================= function callallfunctions() { var aval = document.getelementbyid('myval'); if (getname(aval.value,'abc') == true) { if (validate('abc') == true) { if (checken('def') == true) { return true } else { return false; } } else { return false; } } else { return false; } }
当ajax处理时,它异步工作并返回false。当我合并一个函数中的所有函数,然后它也异步工作并且当ajax正在处理时返回值false
Its working asynchronously and return value false while ajax is under processing. When i merge all the functions in one function then its working asynchronously too and return value false while ajax is under processing
这篇关于异步Javascript回调函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!