Dojo - Remote Script Problem
Posted in dojo, ajax Sun, 04 Jun 2006 04:11:00 GMT
Dojo Toolkit 0.3.0 seems to have a problem loading it's javascript libraries remotely, i.e. when the Dojo scripts are hosted on a server different than where the HTML is. For example, if the page http://www.mysite.com/index.html includes http://www.mystatic.com/dojo/dojo.js. The main Dojo file, dojo.js, runs fine when loaded remotely, however the following fatal errors occur when it attempts to load its external libraries:
FATAL: Could not load 'dojo.io'; last tried '__package__.js' FATAL: Could not load 'dojo.widget.ComboBox'; last tried '__package__.js'
It was suggested this could be due to XSS protections. Scriptaculous' scriptaculous.js, however, has a way around this since it can be loaded remotely and access it's external files (builder.js, controls.js, etc.). Often it's nice to have static files hosted on a separate server. Is there a way to fix this issue for Dojo?
UPDATE 1: For now, I'm going to stick with dojo.io.bind and Scriptaculous autocomplete. A nice thing about this set up is I can load a remote dojo.js browserio build w/o issues since it doesn't need call any external libraries for just bind.
UPDATE 2: Alex Russell provided a uri for cross domain package loading. You can turn on cross domain support by using a custom build and setting the dojoLoader option to xdomain option:
ant -Dprofile=ajax -DdojoLoader=xdomain -Ddocless=true clean release intern-strings
If you don't want to build it yourself, James Burke has done it and made it available as dojo-0.3.1-ajax-xd.tar.gz. This page has some more info.
this isn’t a Dojo problem, it’s the intrinsic cross-domain security model of browsers. We have, however, implemented what we call the “cross-domain package loader”. There’s a wiki page that describes it and how to use it here:
http://dojo.jot.com/CrossDomainPackageLoading
This is something that’s totally new and no other toolkit supports anything like it (mostly because most toolkits haven’t evolved package systems either).
So long story short: you’re working against the grain of the browser, but Dojo still has your back, if you’re willing to put in a little bit of effort (a custom build).
Regards
Thanks for the link. I’ll check it out soon. It’s nice to know even with its more complex architecture, it can still support things like cross-domain library loading.
Regarding the custom build, my understanding is that Java and Ant are required. I don’t have this environment so I’ll have to schedule some time. Custom Dojo builds seem to come up a lot and I’ve been thinking that Dojo would get many more users if either of the following were available:
Have there been any thoughts in these directions?
on the website side of things, dojo is very much a work in progress (though a sturdy one at that) and is in need of people to implement the features you have suggested. a website-based selection feature would be awesome, and you could get google adwords clicks to boot if you set it up.. (-;
i m great full to you, problem solved by var djConfig = { baseScriptUri:’/javascripts/dojo/’ }; putting this
thanks