var beginDate;
var loopMaxTime;
function doBegin(){
loopMaxTime = $("#loopMaxTime").val();
var value1 = $("#param1").val();
var value2 = $("#param2").val();
$.ajax({
type: "POST",
url: contextPath + "/test1.do?t="+new Date(),
dataType: "json",
async: false,
data: {"param1":value1,"param2":value2},
success: function(data){
if( data.SUCCESS ){
beginDate = new Date();
setTimeout("doQueryResult("+data.param3+")",10);
}else{
alert(data.MSG);
return ;
}
},
error:function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});
}
function doQueryResult(param3)
{
$.ajax({
type: "POST",
url: contextPath + "/test3.do?t="+new Date(),
dataType: "json",
async: false,
data: {"param3":param3},
success: function(RESULTDATA){
if( RESULTDATA.SUCCESS ){
if(RESULTDATA.HASDATA)
{
//do submit
document.getElementById('submitBtn').submit();
//
}
else
{
var endDate = new Date();
if(endDate.getTime() - beginDate.getTime() > loopMaxTime)
{
alert("result is not done,time out.");
}else
{
setTimeout("doQueryResult("+RESULTDATA.param3+")",5000);
}
}
}else{
alert(RESULTDATA.MSG);
return ;
}
},
error:function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});