Tobie,

Thanks for your help.  My Web server (Apache/2.0.58 running on IBM AS/
400) is passing the appropriate header information (i.e. 'Content-
Type: application/json'), but when the response is delivered, it's
garbled (i.e. it contains non-printable characters, etc).  It's like
it's being sent is some strange or unknown character set.  While still
garbled, I notice changes in the response when I specify various
charsets in the Content-Type header (e.g. 'application/json;
charset=ISO-8859-1'), however the response remains garbled in all
cases.  Again, here's an example of the response:

�%  ���������� [EMAIL PROTECTED]   ������ z   k%   ������� z   k%   ������ z   k
%   ���� z@   % �%

Does setting the evalJSON property to 'force' introduce a heightened
security risk with regard the the execution of malicious JavaScript
code?  I got this impression from the Prototype documentation, but it
may be an incorrect impression.  Thoughts?

On Apr 14, 7:04 pm, Tobie Langel <[EMAIL PROTECTED]> wrote:
> If you cannot get your server to pass appropriate headers, set the
> evalJSON option to 'force', like so:
>
> new Ajax.Request(url, { evalJSON: 'force', ... });
>
> Best,
>
> Tobie
>
> On Apr 15, 12:00 am, broberts <[EMAIL PROTECTED]> wrote:
>
> > I cannot find any reference to 'defaultchartype' in my config file.
> > However, the Apache config starts out with a number of AddType
> > declarations that look promising...
>
> > AddType text/plain .java
> > AddType text/xml .xml
> > AddType text/x-hdml .hdml
> > AddType text/vnd.wap.wml .wml
> > AddType image/gif .gif
> > AddType text/html .htm
> > AddType text/html .html
> > AddType text/x-component .htc
>
> > Maybe I need to add...
>
> > AddType application/json .js
>
> > Let me know what you think.  I'm going to research it a little more
> > before I make changes the Web server's configuration.
>
> > On Apr 14, 4:53 pm, "Brian Williams" <[EMAIL PROTECTED]> wrote:
>
> > > Apache on the ass/400 never really thunk of it...
>
> > > which version?
>
> > > one thing you might want to check is the defaultchartype in the httpd.conf
> > > file or the server specific directives, thats the first thing i check 
> > > when i
> > > have garbled output like that
>
> > > On Mon, Apr 14, 2008 at 5:45 PM, broberts <[EMAIL PROTECTED]> wrote:
>
> > > > Yes, the code on your server works for me.  Though I didn't seem to me
> > > > that it would make any difference, I had a quick thought that it might
> > > > be that I was using the GET method rather than the POST method.
> > > > However, changing the method had no effect.
>
> > > > I'm using Firebug to inspect the DOM, GET/POST request, and the
> > > > response.  When I get the response back, it's garbled.  As long as I
> > > > specify the content-type as 'text/javascript' (and set the evalJSON
> > > > parm to 'force'), the responseJSON property is populated correctly.
> > > > However, when I set the content-type to 'application/json', the
> > > > response (i.e. responseText property) comes back garbled.  It contains
> > > > non-printable characters.  It's quite strange.  Here's a copy & paste
> > > > of the response:
>
> > > > �%  ���������� [EMAIL PROTECTED]   ������ z   k%   ������� z   k%   
> > > > ������ z   k
> > > > %   ���� z@   % �%
>
> > > > We're running Apache on an IBM AS/400 machine, so our instance of
> > > > Apache might not like the 'application/json' content type.  Have you
> > > > heard of this before?  Can the Apache config file impact the content
> > > > types the Apache Web Server is willing to serve up?
>
> > > > Thanks!
>
> > > > On Apr 14, 4:12 pm, Michael  Stillwell <[EMAIL PROTECTED]>
> > > > wrote:
> > > > > That works fine for me; see:
>
> > > > >http://beebo.org/scratch/test.html
>
> > > > > which Ajax.Requests:
>
> > > > >http://beebo.org/scratch/test.php
>
> > > > > --M.
>
> > > > > On Apr 14, 9:53 pm, broberts <[EMAIL PROTECTED]> wrote:
>
> > > > > > {
> > > > > >         "response": {
> > > > > >                 "status":     "ok",
> > > > > >                 "purpose":    "user",
> > > > > >                 "rtncod":     "1234",
> > > > > >                 "body":       "It worked"
> > > > > >         }
>
> > > > > > }
>
> > > > > > On Apr 14, 3:13 pm, Michael  Stillwell <[EMAIL PROTECTED]>
> > > > > > wrote:
>
> > > > > > > On Apr 14, 6:35 pm, broberts <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > 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".
>
> > > > > > > That should work.  What's the exact JSON that's being returned 
> > > > > > > from
> > > > > > > the server?  If it's a string it needs to be quoted:
>
> > > > > > >   "Hello, World!"
>
> > > > > > > --M.
--~--~---------~--~----~------------~-------~--~----~
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