Having an issue, cant explan where the prob is.. Datatable post error 500, but not always.

Having an issue, cant explan where the prob is.. Datatable post error 500, but not always.

mroyonmroyon Posts: 4Questions: 2Answers: 0

Link to test case:

Debugger code (debug.datatables.net):

js doc ready

$(document).ready(function () {
try {
var _oLanguage = 'ar-KW';
AddAntiForgeryToken = function (data) {
data.__RequestVerificationToken = $('input[name=__RequestVerificationToken]').val();
return data;
};
var baseurl = $('#txtBaseUrl').val();
var input = AddAntiForgeryToken({
token: $(".txtUserSTK").val(),
userinfo: $(".txtServerUtilObj").val(),
useripaddress: $(".txtuserip").val(),
sessionid: $(".txtUserSes").val(),
methodname: "MemLawInfowithPollTableData",
currenturl: window.location.href,
selectedculture: $(".txtSelectedCulter").val()
});
var animcounter = 1.2;

        var dt = $('#MemberCardViewDT').dataTable({
            "bDestroy": true,
            //"retrieve": true,
            "bFilter": true,
            "language": {
                "url": (dir == 'rtl' ? "//cdn.datatables.net/plug-ins/1.10.20/i18n/Arabic.json" : "")
            },

            "columnDefs": [{
                "targets": 0,
                "searchable": true,
                "orderable": false,
            }],

            "pageLength": 8,

            //"oLanguage": _oLanguage,
            "processing": true,
            "serverSide": true,
            "autoWidth": false,
            "responsive": true,
            "ajax": {
                "url": baseurl + "Public/MemberListCardView_TableData",
                "type": "POST",
                "contentType": 'application/x-www-form-urlencoded',
                "dataType": "json",
                "data": input
            },
            "columns": [
                { "title": "fullname" },
                { "title": "cityname" },
                { "title": "photo" },
                { "title": "ex_nvarchar1" },
                { "title": "ex_nvarchar2" }
            ],
            "initComplete": function (settings, json) {
                // show new container for data
                $('#new-list').insertBefore('#MemberCardViewDT');
                $('#new-list').show();
            },
            "rowCallback": function (row, data) {
                // on each row callback
                var li = $(document.createElement('li'));
                li.className = "col-xs-12 col-sm-8 col-lg-3";

                var fullname = data[0];
                var cityname = data[1];
                var photo = data[2];
                var socialdiv = data[3];
                var memberpagelink = data[4];

                animcounter = 1.2 + .2;

                var str = '';
                str += '<div class="col-xs-12 col-sm-6 col-lg-2  text-center offset-lg-1 wow bounceInUp" data-wow-duration="' + animcounter + 's" style="visibility: visible; animation-duration: ' + animcounter + 's; animation-name: bounceInUp;">';
                str += '<div class="team-box  text-center ">';
                str += '   <div class="team-img ">';
                str += ' <a href="#" onclick="' + memberpagelink + '">';
                str += '     <img src="' + photo + '" alt=""  class="img-fluid responsive"/>';
                str += ' </a>';

                str += '</div>';
                str += ' <a href="#" onclick="' + memberpagelink + '">';
                str += '<div class="team-content text-center photocontainer">';
                str += '<h6>' + fullname + '</h6>';
                str += '</div>';
                str += ' </a>';
                str += '</div>';
                str += '</div>';

                li.append(str);

                li.appendTo('#new-list');
            },
            "preDrawCallback": function (settings) {
                // clear list before draw
                $('#new-list').empty();
            }
        });

        $("#MemberCardViewDT_paginate").parent('div').attr('class', 'col-xs-12 col-sm-6 col-lg-2');
    } catch (e) {
        $.alert({
            title: _getCookieForLanguage("_informationTitle"),
            content: e,
            type: 'red'
        });
    }});

```C#

    [HttpPost]
    [ValidateInput(true)]
    [AllowCrossSiteJsonAttribute]
    [ValidateAntiForgeryToken]
    [ExceptionFilter]
    public async Task<ActionResult> MemberListCardView_TableData([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel, GETMemberListEntity input)
    {
        GETMemberListEntity objprofile = new GETMemberListEntity();
        // Initialization.  
        JsonResult result = new JsonResult();
        try
        {
            string search = Request.Form.GetValues("search[value]")[0];


                var items = tut.Select(item => new[]
                {
                    item.fullname,
                    item.cityname,
                    item.photo,
                    item.ex_nvarchar1,
                    item.ex_nvarchar2
                });

                result = this.Json(new { draw = requestModel.Draw, recordsTotal = totalRecords, recordsFiltered = totalRecords, data = items }, JsonRequestBehavior.AllowGet);

        }
        catch (Exception ex)
        {
            return Json(new { status = KAF.MsgContainer._Status._statusFailed, title = KAF.MsgContainer._Status._titleGenericError, redirectUrl = "", responsetext = ex.Message }, JsonRequestBehavior.AllowGet);
        }
        return result;

``` end of code

Error messages shown:

Site
6

Process
9792

Failure Reason
STATUS_CODE

Trigger Status
500

Final Status
500

Description of problem:
Sometimes getting this error, 500 while posting, but after 1 refresh, the error gone for that specific session.

Answers

  • kthorngrenkthorngren Posts: 21,309Questions: 26Answers: 4,948

    This is a duplicate of your other thread. Please don't post duplicate threads. See the answer I provided in your other thread.

    Kevin

This discussion has been closed.