POST
|
Mudit, Thanks a lot for helping on this, really appreciate. However, I made a tiny change to your code that I put another alert at the end of the code. If you run it, you will see the alert with an undefined value first then the alert from the request. I know it's silly but what if I have to pass the value to the alert at the end? How can I do it? Here is my updated code, thanks:
dojo.require("esri.map");
function init() {
var serviceDescriptionStr;
var layersRequest = esri.request({
url: "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer",
content: { f: "json" },
handleAs: "json",
sync: true,
callbackParamName: "callback",
load: function (result) {
serviceDescriptionStr = result.serviceDescription;
alert(serviceDescriptionStr);
},
error: function (error) {
alert(error);
}
});
alert(serviceDescriptionStr); //added by jinnan
}
dojo.ready(init);
Hi, I did some changes and configured the code on JS FIDDLE. Here is the Link and same is tested in IE 8 and chrome. Please try again. Thanks Mudit
... View more
06-12-2014
06:29 AM
|
0
|
0
|
489
|
POST
|
Thanks a lot for your reply, I tested the code by using the way you suggested in both IE 8 and IE 9 and I am still getting the same issue that it won't assign the response into the variable serviceDescriptionStr, which means I still see the undefined variable at the end of the code in the console. Any thought? Thanks. Please try below code. Same is tested in IE 8. var serviceDescriptionStr; var layersRequest = esri.request({ url: "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer/0", content: { f: "json" }, handleAs: "json", sync: true, callbackParamName: "callback", load: function (result) { serviceDescriptionStr = response.serviceDescription; }, error: function (error) { alert(error); }
... View more
06-11-2014
06:00 AM
|
0
|
0
|
489
|
POST
|
Hi guys, I have the code below, it's pretty straightforward and what it dose is making an esriRequest and then assign the serviceDescription of a Feature Layer from the response to a variable.
function getFeatureServerDescription(url){
var serviceDescriptionStr;
require(["esri/request"], function(esriRequest) {
var layersRequest = esriRequest({
url: url,
content: { f: "json" },
handleAs: "json",
sync: true,
callbackParamName: "callback"
});
layersRequest.then(requestSucceeded, requestFailed);
});
function requestSucceeded(response){
serviceDescriptionStr = response.serviceDescription;
console.log('Value from the original response: ' + serviceDescriptionStr);
}
function requestFailed(error){
console.log("Error: ", error.message);
serviceDescription = "";
}
console.log('Value that will be returned to browser: ' + serviceDescriptionStr);
return serviceDescriptionStr;
}
It works fine in Chrome, Firefox and IE 10, the service description is returned and I can see two messages from the console: >Value from the original response: some value >Value that will be returned to browser: some value But issue comes when I run it in IE 9 or 8, it won't assign the response two the variable outside of the esri request object, I see two messages from the console like: >Value that will be returned to browser: undefined >Value from the original response: some value I know it's caused by the non-blocking nature of JavaScript so the code keeps moving along even the response has not come to the callback yet, which made myVariable at the end of the code as undefined. But what I can't understand is why it's working fine in Chrome and Firefox, why would Chrome wait till the response is received and then move along to execute rest of code. So my question is how can I make it work in IE 9? Thanks a lot!
... View more
06-10-2014
09:00 PM
|
0
|
4
|
1299
|
POST
|
Hi ISMAIL, I think the problem is associated with the URL of your FeatureLayer. The correct URL should look like this: url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/Since_1970/MapServer/0" , that means you have to put an URL for an exact layer instead of put URL for entire map service. I don't know which layer you should use but you can try to modify your URL to someting like: "http://gis-server/ArcGis/rest/services/Bijapur/MapServer/0" or "http://gis-server/ArcGis/rest/services/Bijapur/MapServer/1" See if that works. Best, Jinnan Zhang
... View more
03-25-2012
09:40 AM
|
0
|
0
|
178
|
POST
|
See the createPopUpRenderer() function at https://github.com/ArcGIS/ArcGISViewerForFlex/blob/master/src/com/esri/viewer/managers/MapManager.mxml Hi Dasa, thank you for your reply. Could you please give me an example about how to use the "layerInfoWindowRenderer" property for the dynamic map layer? Thanks a lot. Jinnan
... View more
12-14-2011
11:27 AM
|
0
|
0
|
116
|
POST
|
Hello, I have a problem here and really hope somebody could give me some suggestions. I created a customized widget for Flex Viewer which will only allow user to switch on one layer at a time. The layers are dynamic map layers. I am now trying to add the pop-up window function to those layers but really cannot make it work since I am not getting those layers from the main configuration XML; and they are not feature layers. Anybody know how can I add the pop-up function for the Dynamic Map Layer? Thanks a lot.
... View more
12-14-2011
05:49 AM
|
0
|
2
|
423
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|