Hi,

> is prototype broken?

No, I use Ajax functions within classes all the time.

> however, if you encapsulate the code inside a class:
>
> var myclass = Class.create({
>         <cut and paste exact same code into here>
>
> });

If I "cut and paste exact same code into here" I get this:

> var myclass = Class.create({
> new Ajax.Request('somefile.php',{
>         method:'get',
>         onSuccess: function(transport){
>                 var response = transport.responseText || "no response text";
>                 alert("Success! \n\n" + response);
>         },
>         onFailure: function(){
>                 alert('Something went wrong...')
>         }
>
> });
> });

...which creates a new Ajax request immediately and passes it into
Class.create, which is clearly not what you want.

Try this:
http://proto-scripty.wikidot.com/self-contained-test-page

You'll probably figure out what you're doing wrong, and if not, you'll
have a complete example to post when asking for help.
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com


On Dec 6, 4:08 am, evilC <ev...@evilc.com> wrote:
> The following code works:
>
> new Ajax.Request('somefile.php',{
>         method:'get',
>         onSuccess: function(transport){
>                 var response = transport.responseText || "no response text";
>                 alert("Success! \n\n" + response);
>         },
>         onFailure: function(){
>                 alert('Something went wrong...')
>         }
>
> });
>
> however, if you encapsulate the code inside a class:
>
> var myclass = Class.create({
>         <cut and paste exact same code into here>
>
> });
>
> var thisclass = new myclass();
> thisclass.submit();
>
> The code ALWAYS comes back with an empty response when you encapsulate
> the AJAX call :(
>
> Any ideas what I am doing wrong? is prototype broken?

--

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


Reply via email to