I have the following ajax code which am using to get the user details from the server. Am generating the html table from the server side and return the structure as a string. This works fine but i get undefined when user records are too many. What is limitation of data that can be passed in ajax ?
Is there an alternative i can use to generate html table in the client side ?
var param = {};
param.CompanyID = $('[id*=txtCoID]').val();
$.ajax({
type: 'POST',
url: 'AjaxAsync.aspx/BindActiveUsers',
beforeSend: function () { },
data: '{P: ' + JSON.stringify(param) + '}',
contentType: 'application/json; charset=utf-8',
//processData: false,
//timeout: 1000000,
//async: true,
//cache: false,
dataType: 'json',
success: function (rsp) {
document.getElementById('dvUsers').innerHTML = rsp.d;
},
error: function (error) {
document.getElementById('dvUsers').innerHTML = error.d;
}
});
Advertisement
Answer
The problem was caused by the request timeout but not the size of the data. Since I was using ajax updatepanel in aspx project I added AsyncPostBackTimeOut='300000000' to my
ToolkitScriptManager tag and added
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="300000000" />
</webServices>
</scripting>
</system.web.extensions>
to my Web.config file as documented here. Now I can load the data without any problem though it’s taking some time depending with the number of records returned. Thanks for your help.