Javascript Child Function Pass The Return To The Parent Function Return
i want to pass the return from a 'child' (i don't know the correct term) function to the return in the parent function... how is the correct way to do this? check_data() isn't retu
Solution 1:
Since $.post
is an asynchronous function you can't use it to return data on check_data. However you can pass some callback and execute with true/false
argument.
Something like this:
functioncheck_data(type,field,callback){
var chkvalue = $(field).val();
$.post("mods/ajax.fieldchk.php", {
chkvalue: chkvalue,
type: type
},
function(result){
if(result==0){
$(field).css({'background-color': '#faa', 'border': '1px solid #f00'});
callback(true);
}elseif(result==1){
$(field).css({'background-color': '#afa', 'border': '1px solid #0f0'});
callback(false);
}
};
}
Post a Comment for "Javascript Child Function Pass The Return To The Parent Function Return"