//此種為非同步,還不等ajax賦完值,函式就return了。
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;//
//測試
function test(){
var data=getCaseInfoForMap();
alert(data[0].caseId);
//--------------------------------------------------------------------------------------------------------------------------------------------//
//此種為同步async:false,ajax執行不完不會return
var dd="";
url:"<%=path%>/webmodule/constructionDecision/WjInfo/getCommCaseInfoCount.do?timeType="+timeType+"&gridNumber=110105217",
async:false,
return dd;
alert(data);
//此種為非同步,還不等ajax賦完值,函式就return了。
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;//
}
//測試
function test(){
var data=getCaseInfoForMap();
alert(data[0].caseId);
}
//--------------------------------------------------------------------------------------------------------------------------------------------//
//此種為同步async:false,ajax執行不完不會return
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;
}
//測試
function test(){
var data=getCaseInfoForMap();
alert(data);
}