http://prototypejs.org/api/ajax/request

See the bottom paragraph titled "Evaluating JSON headers".  The X- 
JSON header is an HTTP header your server sends, whose value is in  
JSON form.  For example in PHP, you might write:
header('X-JSON: {"response":"valid","msg":"All your base are belong  
to us."}');

As the docs say, "Prototype automatically does so [evals the JSON  
header] and passes it as the final argument of each callback (except,  
obviously, onCreate)..."

Example:
new Ajax.Request('/your/url', {
   onSuccess: function(transport, json) {
     // Remainder of the code
   }
});


TAG

On Mar 16, 2007, at 1:45 PM, Buzzterrier wrote:

>
> Ok, ignorance alert, I cannot find what x-json and how it relates to
> headers. Can you point me in the right direction?
>
> On Mar 15, 3:04 pm, Colin Mollenhour <[EMAIL PROTECTED]>
> wrote:
>> I have used an Ajax.Responder with on302 successfully, but in  
>> Opera the
>> responseText will be blank for anything but 200 so if you need to  
>> pass
>> any data use X-JSON or another header. If you are using onSuccess
>> instead of onComplete in your Ajax.Requests then this is a pretty
>> transparent solution, otherwise I recommend you change all  
>> onComplete to
>> onSuccess so they don't get called when they shouldn't.
>>
>> Colin
>>
>> Buzzterrier wrote:
>>> Hello,
>>
>>> We use a security app that sniffs incoming requests to make sure  
>>> they
>>> are still authenticated. If the user needs to be re-authenticated,
>>> they are redirected to a login page. Upon successful authentication
>>> they are returned to the page of the originating request.
>>
>>> Here is the problem, the server side redirect sends the response  
>>> back
>>> to the httpxmlrequest, where the prototype object dutifully  
>>> inserts it
>>> as html.  I tried capturing the on302, but for whatever reason this
>>> does not get called (httpliveheaders shows a 302, but it never fires
>>> on the browser). The cheesy hack I did was to search for some well
>>> known text in the response, that I know is only on the login  
>>> page. If
>>> it exists I then do a window. location.reload(), which properly  
>>> loads
>>> the login page.
>>
>>> Does someone have a better implementation for this? I while what  
>>> I did
>>> works, it just does not feel right.
>>
>>> Thx.
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to