Select to view content in your preferred language

IE issue - won't load points into a map from esri.request call

1147
5
06-23-2011 07:14 AM
AlistairDorman-Smith
Emerging Contributor
Hi

Everything works fine in all other browsers, but in IE (6,7,8) there's a problem.

Using IE8 and the Dev Tools, I get the following message:

Expected ';'  query?text=&geometry=&geometryType=esriGeometryPoint&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&objectIds=&where=1%3D1&time=&returnIdsOnly=false&returnGeometry=true&maxAllowableOffset=&outSR=&outFields=Operator%2CSector%2Ctotal_heat_load_kWt%2CHeat_Load_Taken_by_CHP_kWt%2CRemaining_Heat_Load_kWt&f=pjson&toJSON=function (key) %7B%0A                return this.valueOf()%3B%0A            %7D, line 2 character 22

It looks like IE thinks the syntax is wrong and I'm missing something, but I can't see any problems.

I've seen a similar thread here: http://forums.arcgis.com/threads/27453-Data-Access-Plain-Text-Sample-not-working but the solution doesn't work for me - I still get an error (in fact in all browsers!)

My code is this:
  var requestHandle = esri.request({
  url: "http://gisserver/ArcGIS/rest/services/6_WGSMSD/MapServer/5/query?text=&geometry=&geometryType=esriGe...",
  content: "http://gisserver/ArcGIS/rest/services/6_WGSMSD/MapServer/5/query?text=&geometry=&geometryType=esriGe...",
  load: requestSucceeded,
  error: requestFailed
   });

As you can see I'm trying to get a JSON output from one of my layers.

And then requestFailed is always being called. The message I'm getting back is:
{
"name":"Error",
"number":-2147352573,
"description":"Member not found",
"message":"Member not found"
}

But I can't seem to find any information on this in Google.

Is there a known issue in IE that has a simple fix to this problem?

And I've tried putting escape() around the URL in the esri.request, but that didn't work.

Grateful for any advice.
0 Kudos
5 Replies
derekswingley1
Deactivated User
Why not just use a query task?

If you really want to use esri.request(), here are a couple of recommendations:
-url should be your URL only and shouldn't include querystring parameters
-content should be your querystring params as key, value pairs in an object
0 Kudos
AlistairDorman-Smith
Emerging Contributor
Thanks for your reply - as you can tell I'm trying to find my way with some of these features of the API so that's helpful to find out about the correct format for the esri.request url and data.

That seems to have been my problem - I've managed to do some changes based on this example here: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/data_requestJson.html

The reason I'm not using a query task is that (I think anyway!) I need to use this Json method in order to remain flexible for importing different JSON feeds onto the map, and also to allow me to use the custom icons for markers without using the identify tool.

But it seems to be working in IE6-8 now so thanks.
0 Kudos
derekswingley1
Deactivated User
Glad you got it working.

Two things:
-if you need to pull JSON data from multiple sources, you'll likely need separate functions to handle the differences in structure
-you can define any symbol you like for geometries/points retrieved with a queryTask
0 Kudos
AlistairDorman-Smith
Emerging Contributor
Sorry for the slight delay in replying.

That's really useful.

Having seen what you have said about being able to use custom icons with the QueryTask, I thought I'd see if I could get it working - using the code that worked from the esri.request code.

I get markers on the map, but they appear at 0,0 lat/long which is odd, and I'm not entirely sure why - I assume it's something to do with the wkid, but the code I'm using below seems correct - but obviously isn't!

If I output the x/y/wikd I get: x - 456309, y - 520207 wkid - 3857 and these come from the layer. My base map is Bing, but I don't see how that would be a problem.

Is there something obvious that I'm doing wrong which is making them appear at 0,0?
Thanks.

  for (var i=0, il=resultFeatures.length; i<il; i++) {
   
   var point_x = resultFeatures.attributes.x;
   var point_y = resultFeatures.attributes.y;
   var point_wkid = resultFeatures.geometry.spatialReference.wkid;
   //console.log(point_x +" "+ point_y +" "+ point_wkid);
   var pointGraphic = new esri.Graphic(new esri.geometry.Point(point_x, point_y, new esri.SpatialReference({ wkid: point_wkid })   ), hmg.markers[4]);

   pointGraphic.setInfoTemplate(infoTemplate);

   map.graphics.add(pointGraphic);
   
      
  }



0 Kudos
HemingZhu
Frequent Contributor
Sorry for the slight delay in replying.

That's really useful.

Having seen what you have said about being able to use custom icons with the QueryTask, I thought I'd see if I could get it working - using the code that worked from the esri.request code.

I get markers on the map, but they appear at 0,0 lat/long which is odd, and I'm not entirely sure why - I assume it's something to do with the wkid, but the code I'm using below seems correct - but obviously isn't!

If I output the x/y/wikd I get: x - 456309, y - 520207 wkid - 3857 and these come from the layer. My base map is Bing, but I don't see how that would be a problem.

Is there something obvious that I'm doing wrong which is making them appear at 0,0?
Thanks.

  for (var i=0, il=resultFeatures.length; i<il; i++) {
   
   var point_x = resultFeatures.attributes.x;
   var point_y = resultFeatures.attributes.y;
   var point_wkid = resultFeatures.geometry.spatialReference.wkid;
   //console.log(point_x +" "+ point_y +" "+ point_wkid);
   var pointGraphic = new esri.Graphic(new esri.geometry.Point(point_x, point_y, new esri.SpatialReference({ wkid: point_wkid })   ), hmg.markers[4]);

   pointGraphic.setInfoTemplate(infoTemplate);

   map.graphics.add(pointGraphic);
   
      
  }





When using eari.request, there are some of the interesting findings I thought might helpful to peers.
var requestHandle = esri.request({
        url: url.path,    //url is a variable for the whole querystring +&f=json
        content: url.query,
             //handleAs: "text",
        load: requestSucceeded,
        error: requestFailed
      }, {useProxy:true});

1. for the same query string with &f=json, if i commented out handleAs:"text", i will get an similar error message. 2. if i commented out {useProxy:true}, i will get an similar error message. Conculsion:
Proxy help to serialize your querysting text for REST quest.
0 Kudos