Hello guys I am having some trouble trying to parse out the returned JSON data from a dijit search. I have the following code where s.set("value","48035") will be populated from another page so for the time being i manually set it to 48035.
var s = new Search({ enableButtonMode: true, //this enables the search widget to display as a single button enableLabel: false, enableInfoWindow: true, showInfoWindowOnSelect: false, map: map }, "search"); s.set("value", "48035");//have tried the following s.search().then(function (response) { var extra = response[0][0].x alert(extra) });//and the followings.search().then(function (response) { var extra = response.candidates[0].location alert(extra.x) }); s.startup();It seems like no matter what i try or do i can not figure out how to get the returned value of x. Here is what the returned JSON data looks like.
{"spatialReference":{"wkid":4326,"latestWkid":4326},"candidates":[{"address":"48035, Clinton Township, Michigan","location":{"x":-82.9172080701955,"y":42.554260928999781},"score":100,"attributes":{"Addr_type":"Postal","Match_addr":"48035, Clinton Township, Michigan","StAddr":"","City":"Clinton Township"},"extent":{"xmin":-82.922208999999995,"ymin":42.549261000000001,"xmax":-82.912209000000004,"ymax":42.559260999999999}}]}If anyone can help me figure this out it would be greatly appreciated or point me in the correct direction.Thanks.
أكثر...
var s = new Search({ enableButtonMode: true, //this enables the search widget to display as a single button enableLabel: false, enableInfoWindow: true, showInfoWindowOnSelect: false, map: map }, "search"); s.set("value", "48035");//have tried the following s.search().then(function (response) { var extra = response[0][0].x alert(extra) });//and the followings.search().then(function (response) { var extra = response.candidates[0].location alert(extra.x) }); s.startup();It seems like no matter what i try or do i can not figure out how to get the returned value of x. Here is what the returned JSON data looks like.
{"spatialReference":{"wkid":4326,"latestWkid":4326},"candidates":[{"address":"48035, Clinton Township, Michigan","location":{"x":-82.9172080701955,"y":42.554260928999781},"score":100,"attributes":{"Addr_type":"Postal","Match_addr":"48035, Clinton Township, Michigan","StAddr":"","City":"Clinton Township"},"extent":{"xmin":-82.922208999999995,"ymin":42.549261000000001,"xmax":-82.912209000000004,"ymax":42.559260999999999}}]}If anyone can help me figure this out it would be greatly appreciated or point me in the correct direction.Thanks.
أكثر...