TypeError: Cannot call method 'insertBefore' of null

771
1
01-26-2014 11:40 PM
PavanAdiga
New Contributor
Hi,

I am using the following ESRI libraries :

dojo.require("esri.map");
dojo.require("esri.layers.MapImage");
dojo.require("esri.layers.MapImageLayer");
dojo.require("esri.geometry.Extent");
dojo.require("esri.SpatialReference");
dojo.require("esri.dijit.HomeButton");
dojo.require("esri.dijit.LocateButton");
dojo.require("esri.InfoTemplate");

dojo.require("esri.layers.FeatureLayer");

dojo.ready(init);

I am getting this error : "Uncaught TypeError: Cannot call method 'insertBefore' of null", when I run the code. The error occurs in "init.js" method of ESRI.

The code works fine when do not use the feature layer and comment it out.

dojo.require("esri.layers.FeatureLayer");

The error only occurs in particular systems, and the code works fine in other system.

This is very confusing. Could anyone point what I am missing out.

Thanks in advance.
0 Kudos
1 Reply
BenFousek
Occasional Contributor III
Welcome to the forum pavan.adiga.

A couple of things:
1) Dojo and the jsapi have moved to AMD style coding. In the interest of creating better apps and getting help here, you should switch as soon as possible.
2) Please wrap your code in code tags. Select your code and click the code button (# sign).
3) You identified the problem as inside your init function, but you didn't post it.
4) insertBefore is very general. This is a javascript method and a method found throughout the dojo (and jsapi) framework. Something in your code is trying to insert a dom node in a parent node doesn't exist. Identifying your issue is going to require posting more code.

Hope this helps.
0 Kudos