Domanda

Forgive me if my verbiage is off but I'm just learning GIS stuff. I'm making an ajax call to a mapping server and in my firebug console, this is exactly what I'm seeing.

jQuery19008239585978290092_1392763042662({
    "displayFieldName" : "name",
    "fieldAliases" : {
    "ID" : "ID",
    "name" : "name"
    },
    "geometryType" : "esriGeometryPoint",
    "spatialReference" : {
    "wkid" : 102100
    },
    "fields" : [
        {
          "name" : "ID",
          "type" : "esriFieldTypeInteger",
          "alias" : "ID"
        },
        {
          "name" : "name",
          "type" : "esriFieldTypeString",
          "alias" : "name",
          "length" : 150
        }
    ],
    "features" : [{
        "attributes" : {
            "ID" : 114,
            "name" : "LewisGale Hospital - Pulaski"
          },
        "geometry" : {
            "x" : -8989914.6998432986,
            "y" : 4448752.1187390834
          }
    }
  ]
});

the ajax calls I'm used to working with do not have the jQuery19008239585978290092_1392763042662 part of it so I'm not sure how to deal with that part of the data.

Below is my success statement:

success: function (json) {
    console.log(json);
},

which is not returning anything which normally would. I think the jQuery19008239585978290092_1392763042662 is throwing me off and I dont know how to deal with the json object or how to traverse it in this format. All I need form this data set is the ID value which in this case is 114.

È stato utile?

Soluzione

The syntax of your log output is that of a function call. The function in question is named jQuery19008239585978290092_1392763042662(), and it's taking a single argument: an anonymous object that looks like the payload of your response.

I suppose it's possible that you're getting odd behavior from Firebug's logging; jQuery runs JSON responses through $.parseJSON() before returning it. Try simply logging the ID in the success handler: console.log('id=', json.features[0].attributes.ID);

It's also possible you're using something other than $.ajax or $.get method with a dataType of json, or $.getJSON. If so, you may have to more explicitly specify the data types and/or accepts values in your AJAX call.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top