XMLHttpRequest responseText is truncated or not returned when return large amounts of data

Posted on 2011-03-04
Last Modified: 2012-05-11

I am developing a web solution that will use javascript to call a WCF Restful service. The javascript is stored in a normal Html page.
I use XMLHttpRequest to send the request to the WCF service and use the responseText from the XMLHttpRequest object to parse the response from the WCF Post.
However if the WCF returns to much information I will get a 12152 status from the XMLHttpRequest object.
Attached is a zip file that contains the following:
1. A SQL script
2. A VS 2010 project

Please do the following steps before opening the VS project:
1. Open the "Create Store Table.sql" script, create a database and run this script, it will create a store table and populate it with 10,000 rows (the script was created and run on SQL server 2008R2)
2. "WCFPoc.sln" this is a VS 2010 project, the file "WCFPoc\Store.svc.cs" needs to be renamed to "WCFPoc\Store.svc" as the upload doesn't except file extensions of .svc
3. In "WCFPoc\App_Data\IStore.cs" the connection string in the GetStores function needs to be set to the DB used where the script in step 1 was run.

Please open the project when the above steps have been completed, the following steps describe the issue that I really need to fix:
1. Select the "SearchStores.htm" file and run the project.
2. Click on one of the buttons in the htm page (do not enter any text in the text boxes)
3. The Results Text box will appear with "Status:12152 Text:Unknown" these is the XMLHttpRequest status code returned when there is to much information.
4. Open "App_Data\IStore.cs" and uncomment the line "//string sql = " and comment the line below this in the GetStores function.
5. Do step 1 & 2 again
6. The reponseText from the XMLHttpRequest object contains valid information.

I have tried a number of different things, but none have helped.
In the Web.config I changed transferMode="Buffered" to transferMode="Streamed", this does return reponseText, however the text is truncated and does not contain all the return information.
I suspect it's nothing to do with the WCF as I have set the maxReceivedMessageSize to 2,147,483,647, I have also set the maxStringContentLength to large number, but they do not effect the results in any way.

Any ideas would be of great help.
Question by:Advoco

Author Comment

ID: 35130044
Increasing points for question
LVL 82

Accepted Solution

hielo earned 500 total points
ID: 35353955
As far as the error code goes, this might shed some light into the mystery:

As for "However if the WCF returns to much information"
Why don't you rethink your strategy. It's not clear to me how you intend to use the data returned by the server, but if upon page load you are retrieving 10000 items to populate a SELECT list, as an end-user, I can't imagine scrolling/reading 10000 items just to select one (or a few).  A better approach would be to implement an autosuggest. Basically you present the user with a text field where s/he begins typing and say after the 3rd character you send an ajax request to the server so that it sends you only the items whose name start with those three characters. This should reduce the number of results you get at once.  It seems more practical and resource efficient.

Now, if you REALLY want all those 10000 records, see if there is a way to increase the memory limit and/or the script execution time.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now