-1
當這個函數被調用時,我想的是,函數等待回調返回對象r
返回一旦回調結束對象
function getWmsLayers(oneServerState){
reader = new GeoExt.data.WMSCapabilitiesReader();;
var serverLayers = new Array();
var store = new GeoExt.data.WMSCapabilitiesStore({
url: OpenLayers.ProxyHost + oneServerState.serverUrl,
reader: reader
});
var isCallBackCompleted = false;
store.load({
callback: function (r) {
return r;
}
});
//Do something ??
return r;
};
layers = getWMSLayers(oneServerState);
歡迎來到**異步**的美妙世界!你不能那樣做。 – SLaks 2013-02-22 20:11:58
當有回調時,這是有原因的。您不必將響應返回給您的代碼,而需要將您的代碼帶入響應中。 – 2013-02-22 20:13:44
你應該回電,不迴應。類似於「稍後問我」... – 2013-02-22 20:15:05