Sample scripts no longer work since upgrade to v3.0 of the API

3853
18
Jump to solution
07-04-2012 07:53 PM
StephenLead
Regular Contributor III
It looks like a batch process has been run over all of the sample scripts, eg the Hover sample, to upgrade them to use version 3.0 of the JS API.

<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.0/js/dojo/dijit/themes/claro/claro.css"> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.0"></script>


This means that the samples no longer work when copy/pasting directly from the Esri site into a local file.

[ATTACH=CONFIG]15775[/ATTACH]

If I revert those lines to use 2.8 the sample works fine.

Thanks,
Steve
0 Kudos
1 Solution

Accepted Solutions
derekswingley1
Frequent Contributor
I'm having a similar problem. Also I am running this from my local file system [ATTACH=CONFIG]15793[/ATTACH]


Please use a local web server. It's not realistic to run web apps from your local file system. There are plenty of free options and most OSes come with a web server built-in.

View solution in original post

0 Kudos
18 Replies
FengZhang2
Occasional Contributor
Seems that you may have a "Access-Control-Allow-Origin" issue for your local html file. You can try to publish the html to the web server and access it using

http://hostmame/.../query_hover.html

Or, the following help links may be helpful to you.

Making cross domain JavaScript requests using XMLHttpRequest or XDomainRequest
http://www.leggetter.co.uk/2010/03/12/making-cross-domain-javascript-requests-using-xmlhttprequest-o...

SCRIPT5: Access is denied in IE9 on xmlhttprequest
http://stackoverflow.com/questions/5793831/script5-access-is-denied-in-ie9-on-xmlhttprequest
0 Kudos
derekswingley1
Frequent Contributor
Steve�?? are you running the sample from your file system or from a local web server?
0 Kudos
NigelAlford
New Contributor III
I'm having a similar problem. Also I am running this from my local file system [ATTACH=CONFIG]15793[/ATTACH]
0 Kudos
derekswingley1
Frequent Contributor
I'm having a similar problem. Also I am running this from my local file system [ATTACH=CONFIG]15793[/ATTACH]


Please use a local web server. It's not realistic to run web apps from your local file system. There are plenty of free options and most OSes come with a web server built-in.
0 Kudos
JeffPace
MVP Alum
Hey derek,
I know this was a change that had to be made, but up till 2.8 everything ran fine as a local file.  It was MUCH more convenient.  This seems like a major step backwards.
0 Kudos
NigelAlford
New Contributor III
I launched this from Visual Studio 2010 Ultimate and everything finally worked. Thats an interesting update with 3.0
0 Kudos
StephenLead
Regular Contributor III
Please use a local web server. It's not realistic to run web apps from your local file system. There are plenty of free options and most OSes come with a web server built-in.


Hi Derek,

Thanks for the clarification. However, I agree with Jeff that this represents a new hurdle for developers (especially those just starting out with the JS API).

While it's not realistic to run web apps from a local file system, it IS common to fire up a quick sample to check how one specific thing works, which is surely the point of the samples? This is how we test out new functionality before compiling it into a robust web app for deployment (not just in the ArcGIS Server JS API but in other web mapping APIs, or indeed other JavaScript/HTML libraries).

I haven't looked into v3.0 yet so I don't fully understand the change, and why it was necessary. As a developer, all I can see is that the copy/paste/test approach used to work, and now doesn't. Perhaps there could be a blog post/tutorial explaining the changes, and giving some simple instructions for the new requirements of a web server - this could be linked on each sample page.

Cheers,
Steve
0 Kudos
MarkHoover
Occasional Contributor II
Hi Derek,

Thanks for the clarification. However, I agree with Jeff that this represents a new hurdle for developers (especially those just starting out with the JS API).

While it's not realistic to run web apps from a local file system, it IS common to fire up a quick sample to check how one specific thing works, which is surely the point of the samples? This is how we test out new functionality before compiling it into a robust web app for deployment (not just in the ArcGIS Server JS API but in other web mapping APIs, or indeed other JavaScript/HTML libraries).

I haven't looked into v3.0 yet so I don't fully understand the change, and why it was necessary. As a developer, all I can see is that the copy/paste/test approach used to work, and now doesn't. Perhaps there could be a blog post/tutorial explaining the changes, and giving some simple instructions for the new requirements of a web server - this could be linked on each sample page.

Cheers,
Steve


Spot on; everything addressed here is a valid concern and well said.
0 Kudos
ReneRubalcava
Frequent Contributor
I believe the reason for this a Dojo 1.7 issue and not an ESRI API issue.
If run locally, Dojo will try to load the files locally, which is why you get these errors.
Let's look at the dojo/text tool. It will load a file as plain text to use in your application, mostly used for templating. This a XHR request, which cannot be done locally and will only work in a server environment.

It can be a little annoying if you are not used to keeping a server up locally.

If you want a ridiculously easy local server to use, try xampp.
http://www.apachefriends.org/en/xampp.html

It's a simple, one-click install of apache/mysql/tomcat and more. You can just use it to run apache which will work for running the samples. There's even a version to run it off a usb drive. I've been using it for quite a while at work so I don't need to work off a test server.
0 Kudos