Having an issue, cant explan where the prob is..

Having an issue, cant explan where the prob is..

mroyonmroyon Posts: 4Questions: 2Answers: 0

this is the code, im working with MVC C#, sometimes, having 500 error and after refresh working fine..

$(document).ready(function () {
try {
var dir = $("html").attr("dir");
var _oLanguage = '';
if (dir == "rtl") {
_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";

                //console.log(data);
                //var eventtitle = data[0];
                //var eventtitlear = data[1];
                //var eventdescription = data[2];
                //var eventdescriptionar = data[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="row">';
                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>';

               // if (socialdiv != '')
                   // str += socialdiv;

                str += '</div>';
                str += ' <a href="#" onclick="' + memberpagelink + '">';
                str += '<div class="team-content text-center photocontainer">';
                str += '<h6>' + fullname + '</h6>';
                //str += '<hr>';
                //str += '<h6>' + cityname + '</h6>';
                str += '</div>';
                str += ' </a>';
                str += '</div>';
                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'
        });
    }

});

controller:

    [HttpPost]
    [ValidateInput(true)]
    [AllowCrossSiteJsonAttribute]
    [ValidateAntiForgeryToken]
    //[LoggingFilterAttribute]
    [ExceptionFilter]
    public async Task<ActionResult> MemberListCardView_TableData([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel, GETMemberListEntity input)
    {

..... 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);

}

Answers

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

    sometimes, having 500 error and after refresh working fine..

    The place to start is with your server logs. They should indicate what is causing the 500 error response. This should point you to the area of your server code to look at.

    Kevin

  • mroyonmroyon Posts: 4Questions: 2Answers: 0

    Tell me something.. I have tried the same without the rowcallback with the same code behind.. working fine with 1000 req.. no error.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    500 is a server error - so whatever you're doing on the client in rowCallback wouldn't affect it as rowCallback is only called after the data has been received.

    As Kevin said, the server logs are the place to start.

    Colin

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

    rowCallback is a client side operation. It wouldn't have any affect on the response from the server. You are seeing the 500 error in the XHR response, correct?

    Kevin

  • mroyonmroyon Posts: 4Questions: 2Answers: 0

    yes, 500 error in the XHR respons.

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

    yes, 500 error in the XHR respons.

    The response is from the server. Have you looked at the server logs yet?

    Kevin

This discussion has been closed.