0

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

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.