Inline, below.

TAG

On Dec 23, 2007, at 1:09 AM, Aea wrote:

> I hope this question isn't too "newbish," but I've been hitting my
> head over what should be a fairly simply problem for the past hour...
>
> Header Sent...
>
> X-JSON = {"a":1,"b":2,"c":3,"d":4,"e":5}

You're sending this as the HTTP header?  Because your code is looking  
for it in the response text.  Which is it?

If you *are* sending JSON in the headers, it should be automatically  
passed in as a second parameter to the function.
onSuccess: function (transport, json) {
     alert(json);
}

> Javascript...
>
> new Ajax.Request('process.php?mode=json', {
>   method:'get',  onSuccess: function(transport){var json =
> transport.responseText.evalJSON(true)}, /*onComplete: alert(json.a)*/
> });

I realize you've got onComplete commented out here, but in this code,  
you've defined the json variable as local to the onSuccess function,  
so it wouldn't be available to the onComplete function ...  (thus,  
undefined)

> Firebug is reporting that json isn't defined. Am I handling JSON wrong
> or what? The official documentation provided this snippet...
>
> new Ajax.Request('/some_url', {
>   method:'get',
>   onSuccess: function(transport){
>      var json = transport.responseText.evalJSON();
>    }
> });
>

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