itsmeprash

Cross Domain Scripting reverseGeocode Service hosted at tasks.arcgisonline.com

Discussion created by itsmeprash on Nov 3, 2011
Latest reply on Nov 3, 2011 by DSwingley-esristaff
Hi

I am trying to invoke a reverseGeocode service hosted at tasks.arcgisonline.com use a simple ajax call.  Initially i got the following error  Origin http://localhost:8181 is not allowed by Access-Control-Allow-Origin.

To avoid the cross domain scripting error i am passing a callback function to this service. Now I keep getting an Unexpected token : error.

Has anybody encountered a similar error making an ajax call to http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_NA_10/GeocodeServer/reverseGeocode

Or is there an api available in the ArcGIS API for JavaScript to do the same.


<!DOCTYPE html>
<html>
<head>
  <style>img{ height: 100px; float: left; }</style>
  <script src="http://code.jquery.com/jquery-1.6.3.min.js"></script>
</head>
<body>
  <div id="images">

</div>
<script>
$.getJSON("http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Address_NA_10/GeocodeServer/reverseGeocode?jsoncallback=?",
  {
   location: "-75.749655520628295,39.68330984653565",
   distance: "5000",
   outSR: "4326",
   f: "pjson"
  },
  function(data) {
   alert(data);
  });

</script>

</body>
</html>

Outcomes