olimpia
25 Apr 2007, 4:04 AM
I am using the code below to do a research in the database
function ValidaPage(oForm){
var IsValid = true;
var oFormLength = oForm.elements.length;
for(var i=0; i<=oFormLength-1; i++ ) {
var oSrcElement = oForm.elements[i];
var postData="field=" + oSrcElement.id;
var hcallback={success:function onSuccess(resp){if (resp.responseText == "false"){IsValid=false;}}};
YAHOO.util.Connect.asyncRequest('POST', "valida.ashx", hcallback, postData);
}
if (IsValid)
return true;
else
return false;
}
}
The connection executed of way asynchronous. I have to await the result of the research in the server to continue the for, as I should do to connect of way synchronous
function ValidaPage(oForm){
var IsValid = true;
var oFormLength = oForm.elements.length;
for(var i=0; i<=oFormLength-1; i++ ) {
var oSrcElement = oForm.elements[i];
var postData="field=" + oSrcElement.id;
var hcallback={success:function onSuccess(resp){if (resp.responseText == "false"){IsValid=false;}}};
YAHOO.util.Connect.asyncRequest('POST', "valida.ashx", hcallback, postData);
}
if (IsValid)
return true;
else
return false;
}
}
The connection executed of way asynchronous. I have to await the result of the research in the server to continue the for, as I should do to connect of way synchronous