When we are return string length more than 60000 from asmx page to js page then “Error in loading” is thrown. Means incase of huge data returning this error is thrown.

When we are return string length more than 60000 from asmx page to js page then “Error in loading” is thrown. Means incase of huge data returning this error is thrown.

Hi,

 

We are using jquery to consume asp.net JSON web services.

using jquery 1.2.3 version, IE 8,visual studio 2008

 

.js page written following code

   $.ajax({

            type: "POST",

            url: "Services/Services.asmx/_featchData",

            data: "{'parentForm':'" + parentForm + "','parentRecordId':" + parentRecordId + ",'formName':'" + formName + "','subObjLable':'" + subObjLable + "','userControlID':'" + userControlID + "','currentPage':" + currPage + ",'pageSize':" + pageVal + "}",

            contentType: "application/json; charset=utf-8",

            dataType: "json",

            success: function(msg) {

                $("#" + userControlID + "_divContainer").get(0).style.display = 'block';

                $("#" + userControlID + "_divContainer").get(0).innerHTML = msg.d;

 

                if (parseInt($("#hdnTotalRecord" + userControlID).get(0).value) > 0)

                    SetPagingValue(userControlID);

                fnShowHideControls(userControlID, true, false, false);

                fnResizeContentRecordView(userControlID);

            },

            error: function() {

                alert("Error in loading!");

            }

        });

Services.asmx written following code

 

[WebService(Namespace = "http://tempuri.org/")]

    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

    [System.Web.Script.Services.ScriptService]

    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.

    // [System.Web.Script.Services.ScriptService]

    public class Services : System.Web.Services.WebService

    {

        int _maxDisplayCharacters = 250;

        [WebMethod(EnableSession = true)]

        //[ScriptMethod(ResponseFormat = ResponseFormat.Json)]

        [ScriptMethod(ResponseFormat = ResponseFormat.Json]

        public string _featchData(string parentForm, int parentRecordId, string formName, string subObjLable, string userControlID, int currentPage, int pageSize)

        {

            ProjectInfo projectInfo = HttpContext.Current.Session[SessionVars.ProjectInfo] as ProjectInfo;

 

            GridViewInfo objGVI = null;

            try

            {

                objGVI = _setSortOrder(parentForm, parentRecordId, formName, subObjLable);

                if (currentPage == 0)

                    currentPage = 1;

                int totalRecords;

                string allIDList = String.Empty;

                DataTable table = null;

                int cntrPage = 0;

                do

                {

                    //deleting all the records from last page Then the Do while loop will excute.

                    if (cntrPage > 0)

                    {

                        currentPage = currentPage - 1;

                        totalRecords = 0;

                        cntrPage = 0;

                    }

                    table = objGVI.getDataSource(currentPage, pageSize, out totalRecords, out allIDList);

                    if (table != null)

                    {

                        if (totalRecords > 0 && table.Rows.Count > 0)

                            break;

                        else if (totalRecords > 0 && table.Rows.Count == 0)

                            cntrPage++;

                        else

                            break;

                    }

                    else

                        break;

                } while (totalRecords > 0 && table.Rows.Count == 0);

 

                string grid = _makeGrid(table, objGVI.Formname, parentForm, parentRecordId, subObjLable, userControlID, totalRecords, currentPage, pageSize, objGVI);

                return grid;

            }

            catch

            {

                string strBuilder = "<table id='" + userControlID + "_Grid'  cellpadding='0' cellspacing='0' style='width:100%;border-style:solid; border-width:0px;border-color:#C9CACC'>";

                strBuilder += "<tr>";

                strBuilder += "<td class='norecord' style='background-color: #ffffff;'>" + Resources.Resource.ContentQuery_Norecordsfound.ToString() + "<BR> " + Resources.Resource.ContentQuery_NoPermission.ToString();

                strBuilder += "</td>";

                strBuilder += "</tr>";

                strBuilder += "</table>";

                strBuilder += "<input id='hdnTotalRecord" + userControlID + "' type='hidden' value='0' />";

                return strBuilder;

            }

 

        }

}}

 

Problem facing: When we are return string length more than 60000 from asmx page to js page then “Error in loading” is thrown. Means incase of huge data returning this error is thrown.

 

Please need some immediate solution because we are stuck here.