2

I'm trying to evaluate a string of 50,000+ characters from an ajax GET request using jquery. On smaller datasets, the code will evaluate it correctly, but firefox throws an error "Unterminated string literal". After some digging, I tried using external libraries from JSON.org, replacing \n, \r\n, and \r with an empty string (on the server), and encapsulating the eval() with parentheses.

Here is some of the client-side code (javascript):

http://pastebin.com/wsXuN7tb <- Here I've used an external library to do it

After looking through firebug, I noticed that the json string returned by the server was not complete, and was cut off at 50,000 or so characters. I know for a fact the server is returning a valid json string because I dumped it to a file before sending it to the client, but the client ends up receiving a truncated version.

Why is this happening? Is there any way around this?

11
  • Check the response headers, and include them in your answer. Do you see any odd header, such as Content-Range?. Also, when you remove all newlines and carriage feeds (\n\r), make sure that every line is still OK (semicolons, parentheses, braces, ...). Commented Oct 9, 2011 at 21:25
  • Nothing out of the ordinary, just CORS headers: pastebin.com/9TDdHzSM Commented Oct 9, 2011 at 21:27
  • Can you provide a link to the 50kB page + relevant XHR code, so I can check it? Commented Oct 9, 2011 at 21:35
  • Also, the json string is sane and can be parsed until something like this happens: {"state":"Online","rel":"Friend","ign":"Silver The Hedgehog","gamename":"Spiral Knights","ingame":"True","steamid":"STEAM_0:1:19011738","avurl":"29/291d18435f94e5e14dbe5d4011ac00b98f545ad9_full.jpg"," Commented Oct 9, 2011 at 21:36
  • Here's the parsing code: pastebin.com/DYy7r4z0 . And here's the (incomplete) response: pastebin.com/b6f8wVXy Commented Oct 9, 2011 at 21:40

2 Answers 2

1

URLs have a length limit that varies from browser to browser. 50,000+ characters is definitely WAY over every browser's limit. For such large data, you should be using a POST instead.

There is quite literally NOTHING you can do about this limit, as it's a browser limit, and not something you can change on the server. The only thing you can go is switch to using POST.

Sign up to request clarification or add additional context in comments.

3 Comments

That's the request limit. The OP is having issues with the response.
I'm implementing this as we speak, but I'm curious to know why this is the case. Shouldn't the response body from a GET request and a POST request be the same?
Turns out the NetworkStream I used in my c# server could not have a buffer that large, so I just wrote half of the buffer, flushed it, and wrote the other half. Thanks for helping guys.
0

Turns out the NetworkStream I used in my c# server could not have a buffer that large, so I just wrote half of the buffer, flushed it, and wrote the other half.

Thanks for helping guys.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.