//This is asynchronous, and it doesn’t wait for ajax to finish assigning the value. The function returns.
function getCaseInfoForMap(){
var formInfo=$("#firstForm").serialize();
var dd;
$.ajax({
type:"post",
url:"<%=path %>/webmodule/constructionDecision/WjInfo/getCaseInfoForMap.do?timeType=" timeType "&gridNumber=" gridNumber,
dataType:"json",
data:formInfo,
success:function(data){
dd=data;
}
});
return dd;//
}
//Test
function test (){
var data=getCaseInfoForMap();
alert(data[0].caseId);
}
//This is synchronous async:false, ajax will not return until it is completed
function getCaseInfoForMap(){
var formInfo=$("#firstForm").serialize();
var dd="";
$.ajax({
type:"post",
url:"< ;%=path %>/webmodule/constructionDecision/WjInfo/getCommCaseInfoCount.do?timeType=" timeType "&gridNumber=110105217",
dataType:"json",
data:formInfo,
async:false ,
success:function(data){
dd=data;
}
});
return dd;
}
//Test
function test( ){
var data=getCaseInfoForMap();
alert(data);
}