View Full Version : Retrieving Javascript

Darth Sensei
04-13-2007, 01:56 PM
I'm attempting to use AJAX to create a configurator for the product my company sells. In essence, I'm importing from a php file the controls that are necessary to configure out product based on the selections the user makes in previous controls.

All of these choices involve javascript to control those controls and validate them. Is it possible to import Javascript as an attached sheet based on the AJAX?

For example, we sell signs and if the user orders a certain type of enclosure there are all sorts of rules to follow. Could I swap (or add) the attached script file on the fly so the user wouldn't be forced to download all of the Javascript for all of the choices beforehand? Much of this js they wouldn't need based on their choices.

Does this make sense?

04-16-2007, 04:09 PM
Yes it is possible (if I correctly understand your question). Here is the code I have in my library for it.

/* global eval code based on blog post on ajaxian written by Joseph Smarr */

exfer.evalCodeToGlobal = function (sJSCode) {
if (window.execScript) {
return null;
var globalNamespace = this;
return(globalNamespace.eval ? globalNamespace.eval(sJSCode) : eval(sJSCode));