Ok - I'm not sure if this more an issue with our setup rather than the code, as it is random. But sometime the creation of a TOC hangs - eventually I get a timeout error.
I tracked this down and occasionally it seems to be hitting www.arcgis.com/sharing/tools/legend to get the legend - of course, with an internal URL it falls over.
I have hacked the code to prevent this
//ACM hack
//if (this.rootLayer.version >= 10.01) {
if (1==1) {
url = this.rootLayer.url + '/legend';
} else {
url = 'http://www.arcgis.com/sharing/tools/legend';
var i = this.rootLayer.url.toLowerCase().indexOf('/rest/');
var soap = this.rootLayer.url.substring(0, i) + this.rootLayer.url.substring(i + 5);
url = url + '?soapUrl=' + escape(soap);
}
As I know my services are greater than 10.01 I can always do this section and rather than remove the 'if' totally I replaced the condition with 1==1
I also put a
console.debug(this.rootLayer.version)
in the code - the times it fails this returns as empty
However
console.debug(this.rootLayer.dpi)
always returns a value, even when version is empty - other properties of this.rootlayer are also fine.
I have no idea why it is happening, but this is my fix I thought I'd share.
ACM