简体   繁体   中英

json ajax call returning success with 200 OK but goes to error with Invalid character

my project is an MVC Web application I am using ajax call to get a huge list of data as JSON.

Here is the code( i am not sure what I a missing ):

  $.ajax({
            url: url, //server
            type: "POST",
            async: true,
            data: { id: id },
            dataType: "json",
            success: function (data) {
                debugger;
                jQuery.each(data, function (i, val) {

//Success code


            },
            error: function (xhr, ajaxOptions, thrownError) {
                console.log(xhr.status);
                console.log(thrownError);
                window.baseShowModalOkCancel("<p>Backlog Data</p>", "<p>Error in Database</p>", "ERROR");
            }
        });
    }

Action Controller:( This is a post method in return statement I can see the list of object with the data.

   [HttpPost]
    [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
    public ActionResult GetBacklogWithData(string id)
    {
        using (var db = new LiensTrackerEntities())
        {

            List<BackLogDataList> backLogData = new List<BackLogDataList>();
            List<BackLogData> backLog;

               backLog = db.BackLogDatas.OrderBy(x =>x.CaseNumber).ToList();
                foreach (var item in backLog)
                {
                    BackLogDataList backLogDataList = new BackLogDataList
                    {
                        FileNo = item.FileNo,
                        BackLogId = item.BackLogID,
                        FirstName = item.FirstName,
                        LastName = item.LastName,
                        Middle = item.Middle,
                        Suffix = item.Suffix,
                        Address = item.Address,
                        Address2 = item.Address2,
                        City = item.City,
                        St = item.ST,
                        Zip = item.SP1ZIP,                           
                        AmaesRecordCreatedDate = item.AMAESRecordCreatedDate != null ? item.AMAESRecordCreatedDate.ToString().Split(' ')[0] : null,
                        AddedInRecipient = item.AddedInRecipient
                    };
                    backLogData.Add(backLogDataList);
                }

            }



            return Json(backLogData, JsonRequestBehavior.AllowGet);
        }
    }

It returns with 200 ok but execute the error function when i look into console i found the following error:

在此处输入图片说明

Thee error is due to max json string length. the solution is

MaxJsonLength exception in ASP.NET MVC during JavaScriptSerializer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM