Select to view content in your preferred language

Issues with 3.0 when Loading App

641
5
07-06-2012 01:39 PM
MarkHoover
Frequent Contributor
I'm not sure if this is a 3.0-specific problem or not, though I never saw the behavior prior to 3.0.

Sometimes (not always) when I load my app, the whole thing fails to load and I get a white screen.  If I click in the lower-left hand corner of IE I get an error message that 'esri' is undefined, leading me to think the call to load the API did not succeed properly (just a hunch though).

Was anything changed in terms of how the API loads itself when called between 2.8 and 3.0?

Sadly I can't access our app using Firefox due to corporate security restrictions but I do have access to Fiddler, if that will help someone identify the issue.
0 Kudos
5 Replies
JK
by
Deactivated User
Same issues here:
Using IE8, when I convert up to to API version 3.0 or 3.1 from 2.8 I get the 'esri' is undefined error and the map hangs without displaying.  When I convert back to 2.8 it works.

Here's the kicker, when I change back to 3.x without any other changes the map loads fine.

IE8
AGS 10.0 SP4

Any help would be great!!!!!!
Thanks.

<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.1"></script>  
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dojox/grid/resources/Grid.css">
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dojox/grid/resources/claroGrid.css">
0 Kudos
derekswingley1
Deactivated User
Are you referencing anything from the esri namespace outside of a function called by dojo.ready/addOnLoad? Due to the new way Dojo loads modules at 1.7, all references to esri.* need to be inside a function called once all modules. We should have had this in the migrating to 3.0 doc but missed it. It'll be there shortly.
0 Kudos
JK
by
Deactivated User
Yes.  So within the <head> tag I have my JavaScript.  So what you're saying in the JS anytime I reference esri.* it needs to reside within a JS function?  An example below is an esri.* reference in my JS code.  The  dojo.addOnLoad(init); is the last line of my JS and resides outside of a function.

var spatialRef = new esri.SpatialReference({wkid:102100});

As long as a reference like the line above is within a JS function{} I shouldn't get the 'esri' is undefined error when using /jsapi/arcgis/?v=3.x   ???


Are you referencing anything from the esri namespace outside of a function called by dojo.ready/addOnLoad? Due to the new way Dojo loads modules at 1.7, all references to esri.* need to be inside a function called once all modules. We should have had this in the migrating to 3.0 doc but missed it. It'll be there shortly.
0 Kudos
JohnGravois
Deactivated User
The important thing to remember is that you have to make sure that no code makes calls to the esri namespace until after the page has loaded.  Since functions don't run until they are directed to run, this makes them a safe location.

As an example, "dojo.addOnLoad(init)" tells your application to fire the init function as soon as dojo indicates that the page is loaded.  calls to esri.* inside init will be fine.
0 Kudos
JK
by
Deactivated User
That helps.  Thanks to both of you for your input.  I think I found the problem.
0 Kudos