Select to view content in your preferred language

Request error unable to load from http://sampleserver6....

7378
20
08-13-2014 04:16 PM
ryannz
by
Deactivated User

Hello everyone, I recently publish my site and it was working fine until today. I got this message:

http://screencast.com/t/BdTyk4X7

Do you know what it is? How can I fix this? When I run the same code locally, it is working fine.

Thanks

Tags (1)
0 Kudos
20 Replies
RiyasDeen
Regular Contributor

ryan nz wrote:

Owen, I inspected element using google chrom and here is the error:

XMLHttpRequest cannot load http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geomet…43794057776715%2C%22spat.... The 'Access-Control-Allow-Origin' header has a value 'http://localhost:6179' that is not equal to the supplied origin. Origin 'http://example.com' is therefore not allowed access.

The message seems to refer to localhost. Where can I change that?

Hi Ryan,

I got the URL from your previous post above.

Below modified click event for "good" button. This should work without any issues cross site scripting issues.

On(dom.byId("good"), "click", function(evt) {

  ioScript.get({

  url: "http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project", // Project URL

  callbackParamName: "callback",

  content: {

  f: "json",

  outSR: "102100",

  inSR: "4326",

  geometries: dojo.toJson({

  geometryType: "esriGeometryPoint",

  geometries: [ // List of your geometries.

  new Point(174.10266423100921,-39.04732347299239, new SpatialReference({ wkid: 4326 })),

  new Point(174.10538328709313,-39.04732347299239, new SpatialReference({ wkid: 4326 })),

  new Point(174.10538328709313,-39.043794057776715, new SpatialReference({ wkid: 4326 })),

  new Point(174.10266423100921,-39.043794057776715, new SpatialReference({ wkid: 4326 }))

  ]})

  },

  load: function (data) {

  alert(data.geometries.length);

  },

  error: function (error) {

  alert("asdads");

  }

  });

  });

0 Kudos