Go Premium for a chance to win a PS4. Enter to Win


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

Posted on 2011-03-04
Medium Priority
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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses how to create an extensible mechanism for linked drop downs.
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…
Suggested Courses

782 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