Doubt in AJAX
i go tto perform some validation while ck=liking a button without refreshing the value.. i used ajax.My code is as follows...on button click i call the function validateGridAdd();
Inside tat function i need to call the function tat uses ajax to go to the server and come back.. the resultant value is to be obtained in the main function validateGridAdd().
//main function
function validateGridAdd(a,rowNum){
var tForm = document.hallAllotFrm;
if(!validateCommon()){
return;
}
getValidation();
var length = document.getElementsByName("arrInv").length;
var invArr = document.getElementsByName("arrInv");
var currInv = document.getElementById("arrInv0");
var currRel = document.getElementById("arrReliev3");
if(currInv.value==currRel.value){
alert('Supervisor and Relieving Faculty cannot be same person.');
returnfalse;
}
returntrue;
}
//function for ajax
function getValidation(){
var tForm = document.hallAllotFrm;
var invig = document.getElementById("arrInv0").value;
var fromTime = document.getElementById("arrFrom1").value;
var toTime = document.getElementById("arrTo2").value;
var examDate = document.getElementById("date").value;
var url ="validateSchedule.action?invigId=" + invig+""+'&fromTime='+fromTime
+""+'&toTime='+toTime+""+'&examDate='+examDate+""+'&flag='+flag;
populateSelectBoxes(url);
}
function populateSelectBoxes(url){
if (window.XMLHttpRequest){
req =new XMLHttpRequest();
}elseif (window.ActiveXObject){
req =new ActiveXObject("Microsoft.XMLHTTP");
}
req.open("GET", url,true);
req.onreadystatechange = populateTextField;
req.setRequestHeader('Accept','message/x-jl-formresult');
req.send(null);
}
function populateTextField(){
if (req.readyState == 4 && req.status == 200){
value=req.responseText;
if(value=="true"){
alert("Supervisor scheduled for class.Please select another supervisor");
document.getElementById("arrInv0").value=-1;
}
}
document.getElementById("flag").value=value;
}
ive got a hidden variable "flag" in my code.. tat variable is set to the responseText in my function. i need to get the responseText in my main function validateGridAdd(a,rowNum);
the value of flag can be eithr true or false.
How do i get this value in the main function.?

