Two Laptop Bag
The moose likes HTML, CSS and JavaScript and the fly likes how many bytes can XMLHttpRequest.responseText hold? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "how many bytes can XMLHttpRequest.responseText hold?" Watch "how many bytes can XMLHttpRequest.responseText hold?" New topic
Author

how many bytes can XMLHttpRequest.responseText hold?

Caly LeeAnn
Ranch Hand

Joined: Nov 22, 2005
Posts: 55
I have been trying to send a large chuck of data to a JSP file through XMLHttpRequest.responseText. But my data is truncated and I can only receive around 50k instead of 300k which is what I send. Is there a length limit for XMLHttpRequest? If so, is there any way to send a large chuck of data using XMLHttpRequest?

Any advice will be appreciated.

Thank you.

Caly
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
Is this plain text/JSON. Are you setting this text in the body?

Eric
Caly LeeAnn
Ranch Hand

Joined: Nov 22, 2005
Posts: 55
It's plain text.

I send a XMLHttpRequest to a Servlet in a JSP file. And in the Servlet I use ServletOutputStream to send the data back to the JSP.

I didn't set text/JSON in the header, though. Does it affect the length of the data that can be retrieved?
[ September 06, 2006: Message edited by: Caly LeeAnn ]
Caly LeeAnn
Ranch Hand

Joined: Nov 22, 2005
Posts: 55
I set the contentType to 'text/JSON' but it doesn't make a difference. I can still only receive around 50k data.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56224
    
  13

There is no standard mime type text/json. I also don't see what the content type would have to do with this issue.

Are you setting content-length?

If you hit resource directly with the browser, does the entire content body get loaded?


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Caly LeeAnn
Ranch Hand

Joined: Nov 22, 2005
Posts: 55
I set the contentType to 'text/JSON' but it doesn't make a difference. I can still only receive around 50k data.
Caly LeeAnn
Ranch Hand

Joined: Nov 22, 2005
Posts: 55
Bear,

I didn't set the content length for the XMLHttpRequest. If I send a request through HttpRequest, I don't have this problem.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56224
    
  13

"text/JSON" isn't a valid mime type either, it should be "text/plain".

What happens if you set the content-length?
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: how many bytes can XMLHttpRequest.responseText hold?
 
Similar Threads
AJAX lag issue
How JavaScript talk with Server ?
Ajax technique for a list of entries
how can I modify a bean's property only by html button?
Success function of jquery ajax do not run. Whats the problem?