Hi T.J,

Thanks for the response!

I got it to work, but I had to make some changes...

In 1.5, it used to return the actual response text from json, not the
header. The code is set to assign a variable to take that response
(see my example in the original post). Example:

// php file
$arrSomeStuff['name'] = "John Smith";
$arrSomeStuff['city'] = "Toronto";
echo json_encode( $arrSomeStuff );

// js file
onComplete: function(response, arrSomeStuff){
        $('name_div').update(arrSomeStuff.name);
}

On 1.6, after some tinkering, the only way I could get it to work was
by making these changes:

// on the php file
header('Content-type: application/json');
echo json_encode( $arrSomeStuff );

// on the js file
onComplete: function(response){
        var arrSiteVariable = response.responseJSON;
}

At this point, I guess my only question is, is there a way to get the
actual response on the second argument passed? (you know, without
massive changes...). Also, any particular reason the header was sent?
What is that useful for?

Thanks again!

-yaz

On May 4, 6:31 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote:
> Hi,
>
> > There have been some interesting issues, and mostly I've fixed (with
> > no help from the deprecation script, as it doesn't work).
>
> Have you filed bug report(s) for the way/ways in which you don't think
> it works? (Although at this point, as it's been two and a half years
> since 1.6.0 was released, I'm not sure the core devs would action
> them.)
>
> > So, one issue I've come accross, I need to know if passing a second
> > parameter to the onComplete Ajax.Request is still possible.
>
> The onComplete callback still receives a second argument:
>
> "...all callbacks (except onException) are invoked with two
> parameters: the Ajax.Response object and the result of evaluating the
> X-JSON response header, if any (can be null)."[1]
>
> So as long as your PHP code is sending the result from json_encode as
> a response header with the name X-JSON, it should be showing up in
> your onComplete handler.
>
> [1]http://api.prototypejs.org/ajax/
>
> HTH,
> --
> T.J. Crowder
> Independent Software Consultant
> tj / crowder software / comwww.crowdersoftware.com
>
> On Apr 30, 10:02 pm, Yaz <yasm...@gmail.com> wrote:
>
>
>
> > Hi all,
>
> > I've have been working with a *lot* of javascript code, all done in
> > prototype 1.5. The company I work for, has decided to upgrade
> > prototype libraries. So I have upgraded prototype and scriptaculous,
> > and about 5 others.
>
> > There have been some interesting issues, and mostly I've fixed (with
> > no help from the deprecation script, as it doesn't work).
>
> > So, one issue I've come accross, I need to know if passing a second
> > parameter to the onComplete Ajax.Request is still possible.
>
> > There are a ton of Ajax.Request calls like this:
>
> > new Ajax.Request('some_url.php', {
> >         parameters  : Parameters,
> >         evalScripts : true,
>
> >         onComplete: function(response, arrSomeStuff){
> >                 // from php arrSomeStuff is passed like this
> > json_encode(arrSomeStuff);
> >                 $('some_div').update(arrSomeStuff.value_name);
> >         },
>
> >         onFailure: function(response){
> >                 // handle errors
> >         }
>
> > });
>
> > Now, I don't know why the arrSomeStuff was passed along as a second
> > argument, as response has the same information. But, the advantage,
> > was that in 1.5, that array came perfectly, you didn't have to get it
> > out of the response var.
>
> > But, it doesn't work on 1.6. And there is too much code for me to try
> > to adapt this (30 files, each using it about 20 times).
>
> > So far, everything works, except it doesn't execute the update because
> > arrSomeStuff.value_name is null.
>
> > Any ideas??
>
> > Thanks!! :)
>
> > --
> > 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 
> > athttp://groups.google.com/group/prototype-scriptaculous?hl=en.
>
> --
> 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 
> athttp://groups.google.com/group/prototype-scriptaculous?hl=en.

-- 
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