I am receiving the following error when attempting to connect to a sample rest service provided the the Arcgis Javascript API docs.
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://bcgphp' is therefore not allowed access.
Following the dojo docs I have setup my dojo/store as follows.
var jsonStore = new JsonRest({
target: "//sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/"
});
jsonStore.get(5);
I have also tried passing in some headers per the dojo docs, which returned the same error as the code above.
var jsonStore = new JsonRest({
target: "//sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/",
headers: {'X-Requested-With': 'XMLHttpRequest'}
});
jsonStore.get(5);
When I use the Arcgis Javascript to Query I am able to make this request with the following code provided in this demo This does not cause any cross domain issues.
var queryTask = new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5");
var query = new Query();
query.returnGeometry = false;
query.outFields = [
"SQMI", "STATE_NAME", "STATE_FIPS", "SUB_REGION", "STATE_ABBR",
"POP2000", "POP2007", "POP00_SQMI", "POP07_SQMI", "HOUSEHOLDS",
"MALES", "FEMALES", "WHITE", "BLACK", "AMERI_ES", "ASIAN", "OTHER",
"HISPANIC", "AGE_UNDER5", "AGE_5_17", "AGE_18_21", "AGE_22_29",
"AGE_30_39", "AGE_40_49", "AGE_50_64", "AGE_65_UP"
];
queryTask.execute(query, showResults);
function showResults (results) {
console.log(results);
}
I would really like to use the dojo.store if possible so that I can structure my app using the MVC technique provided by Dojo