This seems excessive. Just do:var pathToJS = "...";
 var j = new Element('script', {
     type: "text/javascript",
     language: "javascript",
     src: pathToJS
});
$(document.body).insert(j);

That way the browser does the loading for you.

You're problem is likely that javascript is technically CDATA, so you can't
just insert it into script tags. Also, you shouldn't post this kind of stuff
on Prototype-Core.Try
http://groups-beta.google.com/group/prototype-scriptaculous

Allen Madsen


On Fri, Aug 14, 2009 at 11:07 AM, Fray <cilibe...@gmail.com> wrote:

>
> People: i had been searching the web to find some way to load a piece
> of javascript code on demand. So far the only method thats works is
>
> var ServerObject = Class.create({
>        initialize: function() {
>                this.the_script = "";
>                new     Ajax.Request(arguments[0], {
>                        contentType: "text/javascript",
>                        asynchronous: false,
>                        onSuccess: function(t) {
>
>                        var j = new Element('script', {
>                                        type:           "text/javascript",
>                                        language:       "javascript"
>                                });
>                                j.innerHTML = this.the_script;
>                                document.body.appendChild(j);
>                                //eval(t.responseText);
>                        },
>                        onFailure: function(t){
>                                alert(t.responseText);
>                        }
>                });
>                return eval(this.el_script);
>        }
> });
>
> This works only on mozilla. I can“t find a way to make a method or
> function well. (cross browser an clean)
>
> Thanks, and sory about my english is quite forgotted.
> Federico Ciliberti.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to