function kadcmkinfo1(lotno){ qKADCMKinfo = new esri.tasks.QueryTask("http://xx.xx.xx.xx:8399/arcgis/rest/services/v_pv/MapServer/9");//layer 9 V_PV_LOT_PROPLST_PROPLST_DETL var content1 = ""; var queryInfo = new esri.tasks.Query(); //queryInfo.returnGeometry = false; queryInfo.outFields = ["*"]; //queryInfo.where = "LOT_NO_FORMATED = '" +lotno+ "'"; //"NOLOT='"+ lotNo.replace("LOT", "Lot") +"' and h_lokasi='PRESINT "+ prct +"'"; queryInfo.where = "LO_NO = 0007460"; qKADCMKinfo.execute(queryInfo); dojo.connect(qKADCMKinfo,'onComplete',function(fInfo){ //onComplete var ptLot = "", ptBldgNo = "", ptValType = "", ptAnnlVal = "", ptDesc = ""; var resultA = fInfo.features; if (resultA.length == 0) alert("no value"); alert(lotno); content1 = "<table border='1'><tr><th><b>"+lotno+"</b></th></tr>"; for (var i=0; i=resultA.length; i++){ alert(i); var grpc = resultA; ptLot = grpc.attributes["LOT_NO_FORMATED"]; alert(ptLot); content1 += "<tr><td> Valuation Type :</td><td>" + ptLot + "</td>"; content1 += "</tr>"; } content1 +="</table>"; }); return(content1); }
qKADCMKinfo.execute(queryInfo, function (fInfo) {//onComplete callback var ptLot = "", ptBldgNo = "", ptValType = "", ptAnnlVal = "", ptDesc = ""; var resultA = fInfo.features; if (resultA.length == 0) alert("no value"); alert(lotno); content1 = "<table border='1'><tr><th><b>" + lotno + "</b></th></tr>"; for (var i = 0; i = resultA.length; i++) { alert(i); var grpc = resultA; ptLot = grpc.attributes["LOT_NO_FORMATED"]; alert(ptLot); content1 += "<tr><td> Valuation Type :</td><td>" + ptLot + "</td>"; content1 += "</tr>"; } content1 += "</table>"; }, function (e) { //onError callback alert("Error!!!"); });
I would use the already "hooked" up portion of the callback within the queryTask.execute. The usage for .execute is below
execute(parameters, callback?, errback?)
The "callback?" is where you would place your code that you have attempted to use the dojo.connect to below:
,function(fInfo){ ...etc..
You might want to try something like this insteadqKADCMKinfo.execute(queryInfo, function (fInfo) {//onComplete callback var ptLot = "", ptBldgNo = "", ptValType = "", ptAnnlVal = "", ptDesc = ""; var resultA = fInfo.features; if (resultA.length == 0) alert("no value"); alert(lotno); content1 = "<table border='1'><tr><th><b>" + lotno + "</b></th></tr>"; for (var i = 0; i = resultA.length; i++) { alert(i); var grpc = resultA; ptLot = grpc.attributes["LOT_NO_FORMATED"]; alert(ptLot); content1 += "<tr><td> Valuation Type :</td><td>" + ptLot + "</td>"; content1 += "</tr>"; } content1 += "</table>"; }, function (e) { //onError callback alert("Error!!!"); });
Note all I did was copy your code and I reorganized. I never looked at the code within to ensure that it was structured correctly.
myDynamicLayer = esri.layers.ArcGISDynamicMapServiceLayer("http://xx.xx.xx.xx:8399/arcgis/rest/services/v_pv/MapServer",{ id: "dynamicLayer1", opacity:0.5 });