Reputation: 227
iam using ajax auto suggest function as follows
$("#empName2").autocomplete({
search: function (event, ui) {
var key = CheckBrowser(event);
if (key == 13)
return true;
else
return false;
},
source: function (request, response) {
$.ajax({
url: '@Url.Action("EmployeeAutoSuggestByName", "LeaveDetail")',
data: { autoSuggestText: request.term
},
dataType: 'json',
type: 'POST',
success: function (data) {
alert(data);
response(data);
}
});
},
select: function (event, ui) {
$("#empID2").val(ui.item ? ui.item.id : 0);
}
});
and i supply json data from controller..everything work perfect for small amount of data..but when it comes to long data..ajax sucess function not even working..i placed an alert in ajax success function.but its not getting hit.but when i use small json strings everything work perfect..is there any size limit for data ajax can receive?.what could be the problem??.im using asp.net mvc3
Upvotes: 0
Views: 3719
Reputation: 197
I have faced the same issue in my project and solved the issue by adding the line of code in webconfig
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="5000000">
<converters>
</converters>
</jsonSerialization>
</webServices>
</scripting>
</system.web.extensions>
The default value for maxJsonLength is 102400. For more details, see this MSDN page: http://msdn.microsoft.com/en-us/library/bb763183.aspx
Upvotes: 1
Reputation: 2653
You can set the JSON maxJsonLengthin web config
<configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000000"/>
</webServices>
</scripting>
</system.web.extensions>
</configuration>
http://msdn.microsoft.com/en-us/library/bb763183.aspx
Upvotes: 3