The problem of one function getting the return value of another function in js is discussed
//This is asynchronous, and the function returns before the ajax assignment is complete.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;//}// testfunction test(){var data=getCaseInfoForMap();alert(data[0].caseId);}
//This is the synchronization async:false,ajax execution will not returnfunction 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;}// testfunction test(){var data=getCaseInfoForMap();alert(data);}