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

741
2
11-03-2011 09:54 AM
PrashanthSukumaran
New Contributor II
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/reverseGe...

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>
0 Kudos
2 Replies
derekswingley1
Frequent Contributor
Why not use the API for this?
0 Kudos