SyntaxError:在parse<anonymous>

问题描述

我需要一些有关此错误的帮助:

SyntaxError:JSON输入意外结束 在解析() 在vendor.bundle.js:1 在S(vendors.bundle.js:1) 在XMLHttpRequest。 (vendors.bundle.js:1)

enter image description here

这是我在控制器中的功能

   public JsonResult PopulateEnableBookRequest(int ? id)
    {
        var listofBooks = new List<BookRequestviewmodel>();
        int OrgId = (Int32)Session["OrgId"];
        //BookRequestviewmodel model = new BookRequestviewmodel();
        int LicId = (Int32)Session["GlobalLicenseId"];
        using (MarketEntities db = new MarketEntities())
        {
            listofBooks = (from br in db.BookRequests
                           join brd in db.BookRequestDetails on br.RequestNo equals brd.RequestNo
                           join t in db.marketingrectypes on brd.ReceiptTypeId equals t.id
                           where br.EmployeeId == id //for test
                           && brd.FinanceApproval == 0 && br.OrgId == OrgId && t.LicenceId == LicId
                           select new BookRequestviewmodel()
                           {
                               Id = brd.Id,RequestNo = br.RequestNo,EmployeeId = br.EmployeeId,ReceiptTypeId = brd.ReceiptTypeId,bookTypeName = t.name,Amount = brd.Amount,RequestDate = br.RequestDate,SupervisorApproval = brd.SupervisorApproval,FinanceApproval = brd.FinanceApproval
                           }).ToList<BookRequestviewmodel>();
        
        }
        if (listofBooks.Count() == 0)
        {
            listofBooks = null;
            return Json(listofBooks,JsonRequestBehavior.AllowGet);
        }
        return Json(listofBooks,JsonRequestBehavior.AllowGet);
    }

这是viewData

            ViewData["EnableBookRequest"] = PopulateEnableBookRequest(id);

这是我在Java脚本中的功能

    $("#empList").change(function () {

     var selectedvalue = $("#empList option:selected").val();
      $.ajax({
         type: 'GET',url: '/BookRequests/PopulateEnableBookRequest?id=' + selectedvalue,dataType: 'json',contentType: 'application/json charset=utf-8',success: function (data) {
                    if ('@ViewData["EnableBookRequest"]' == 0) {
                        $('#add').removeClass('btn m-btn--pill')
                        $('#add').addClass('btn btn-accent m-btn--pill')                      
                    }
                    else {
                        $('#add').removeClass('btn btn-accent m-btn--pill')
                        $('#add').addClass('btn m-btn--pill')
                    }

                },error: function (xhr,status,error) {
                    //alert(selectedvalue);
                    console.log(error);

                }
            });
        });

anone可以帮我吗:(?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)