Re: [json] compressed JSON with AJAX
- Well I'm not sure what's going on on your end, but I use JSON strings being
received via an XMLHTTPReq process all the time and have never had to "Esc"
the results as you mention.
Can you post a small section of the JSON response text so we can take a look
at it here? Perhaps there's something there which might give us a clue.
Also, one of the things I do when troubleshooting AJAX type code is to use
Firefox and the Firebug extension.
They work GREAT together and have saved me untold countless hours of trying
to debug AJAX related problems.
Hope this helps out.
On 10/1/06, ianscottspiro <ispiro@...> wrote:
> I joined this group yesterday because I was having a problem with JSON.
> While my
> membership was getting approved, I came up with a solution, but I will
> post anyway in
> case there is a more efficient way.
> I am building an AJAX application that requires a data format. The user
> needs to be able to
> save data into a file which can be uploaded later for subsequent use. My
> data format is
> simply a gzipped file that contains a JSON string. At first, I was taking
> the uploaded file
> and decompressing it at the PHP level and just echoing it out into a
> my html. This seemed redundant since it meant the user would have to
> download the fully
> decompressed JSON string instead of the already gzipped version. I wanted
> to move
> toward a solution that used XMLHttpRequest. I changed my code so that
> after the file is
> uploaded, an XMLHttpRequest is spawned off to grab this file. I was very
> happy to find that
> XmlHttpRequest will automatically unzip the data after receiving it. I put
> this data into a
> string, but JSON couldn't parse it back into an object. It was a problem
> with escaping. The
> following solved the problem:
> aJSONtext=new Function("return \""+xmlhttp.responseText+"\"")();
> This is stripping off one layer of escaping. Turning \" into ". But how
> compatible is this? It
> seems like a hack and I'm surprised there isn't another way to use JSON
> data that is
> Thanks in advance!
[Non-text portions of this message have been removed]