In Firefox 2.x and IE6 (the browsers I've tested in thus far), the
responseJSON property of the Ajax.Response object is null when I set
the response content-type to "application/json".

However, when I set the response content-type to "text/javascript",
the responseJSON property actually contains the JavaScript object as
expected.  Also, if I don't set the evalJSON property to 'force', I
get nothing in the responseJSON.  However, there's no cross-site
scripting issue.  It's a 'relative' GET request, so it's definitely
obeys the same-origin policy.

Any ideas?  Here's the code segment:

// Random number to randomize the request URL and avoid browser/proxy
caching
var rand = Math.random();

// Serialize the form data into JavaScrip object in preparation for
submission via ajax
var form_data_obj = $('formdata').serialize(true);

var request_url = "myprogram.php?task=addtocart&ajax=1&rand="+rand;

new Ajax.Request(request_url, {
        method: 'get',
        parameters: form_data_obj,
        evalJSON: 'force',
        onSuccess: function(transport){
                var temp = '';
                for(var x in transport.responseJSON){
                        temp += (x+"\n");
                }
                alert(temp);
        },
        onFailure: function(transport){
                // Nothing yet
        }
});
--~--~---------~--~----~------------~-------~--~----~
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 rubyonrails-spinoffs@googlegroups.com
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