Getting Ajax error while using dataTables 1.10 with C# WebServices

Getting Ajax error while using dataTables 1.10 with C# WebServices

joebabu4ujoebabu4u Posts: 7Questions: 3Answers: 0
edited October 2017 in Free community support

If I add "contentType": "application/json; charset=utf-8" while calling C# web service, i am getting AJAX error. i dont see the request is reaching to My Web Service.

But if remove the contentType, it works and goes to Web Service. This time, it gives the same error after returning json from Web Service.

My Source sample code is loaded in the following URL.

https://jsfiddle.net/dx9g6n7L/1/

Regards,
Joe

Answers

  • kthorngrenkthorngren Posts: 20,277Questions: 26Answers: 4,766

    What is the error you receive?

    Does the error message contain a link to a tech note with troubleshooting steps? If so what are your results?

    Kevin

  • joebabu4ujoebabu4u Posts: 7Questions: 3Answers: 0

    I am getting "DataTables warning: table id=resProDataTable - Ajax error. For more information about this error, please see http://datatables.net/tn/7".

    If I follow the steps as per Error URL, i am getting the following message in browser developer tools.

    {"Message":"There was an error processing the request.","StackTrace":"","ExceptionType":""}

    I have also uploaded same code in https://jsfiddle.net/dx9g6n7L/1/. You will be getting same error while running this code in jsfiddle.

    Regards,
    Joe

  • kthorngrenkthorngren Posts: 20,277Questions: 26Answers: 4,766

    In the fiddle I'm seeing this response:

    Request URL:https://fiddle.jshell.net/webservices/datatables.asmx/GetAllTickets
    Request Method:POST
    Status Code:404 NOT FOUND
    Remote Address:162.243.36.109:443
    Referrer Policy:no-referrer-when-downgrade
    

    You will need to look at the server logs to determine why the 404 error is being returned.

    Kevin

  • joebabu4ujoebabu4u Posts: 7Questions: 3Answers: 0

    In Server, Webservice is available.. i am getting the following error in developer tools. If i remove contentType, then it is reaching webservice.. i can see this in debugging mode. Otherwise it gives error, before reaching to webservice itself.

    Status Code:500 Internal Server Error

    "{"Message":"There was an error processing the request.","StackTrace":"","ExceptionType":""}".

    I am not sure how to attach web service in jsfiddle. Kindly let me know how to proceed on this.

    Also can you tell me whether my script code right or not.

    Regards,
    Joe

  • kthorngrenkthorngren Posts: 20,277Questions: 26Answers: 4,766
    edited October 2017

    The "500 Internal Server Error" is also a server error. Again you would need to look at the server logs to find out why its responding with a "500 Internal Server Error". The reason found in the logs will help determine if the problem is with your script configuration or with something on the server side.

    Depending on how the server is configured to accept requests will determine how to configure your script.

    Kevin

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    You should be able to go straight your datatables.asmx, as if it were a normal page. With that, you can test your web service to confirm your problem is serverside or client side.
    Do you have scripting services enabled at the top of your asmx page?

    I don't see you using dataSrc option in your ajax. Datatables does not know that web services always return its result set in an object called "d".

    Be sure to check out some of the other posts related to webservices and webmethods both here and StackOverflow

  • joebabu4ujoebabu4u Posts: 7Questions: 3Answers: 0

    Hi,
    Could you please guide me how to check Server logs?.. i am using windows 10 for development..

    But i am not sure how come only datatables 10 is not working.

    The following code which use legacy is working fine.

    https://jsfiddle.net/dx9g6n7L/2/

    '''
    $(document).ready(function () {
    $("#resProDataTable").DataTable({
    "processing": true,
    "serverSide": true,
    "sAjaxSource": "/webservices/datatables.asmx/GetAllTickets",
    "columnDefs": [
    { orderable: true, "targets": 0,data: "smTicketNo" },
    { orderable: true, "targets": 1,data: "smEmpName" },
    { orderable: true, "targets": 2,data: "smStatus" },
    { orderable: true, "targets": 3,data: "smCustomerName" },
    { orderable: true, "targets": 4,data: "smProdName" },
    { orderable: true, "targets": 5,data: "smDateReceived" },
    { orderable: true, "targets": 6,data: "smWorkStartDate" },
    { orderable: true, "targets": 7,data: "smWorkEndDate" },
    { orderable: true, "targets": 8,data: "smTotalTime" },
    { orderable: false, "targets": 9,data: "smProblemDescription", "sWidth": "30%" },
    { orderable: true, "targets": 10, data: "smRating" }],
    "fnServerParams": function (aoData) {
    aoData.push(
    { "name": "TicketNo", "value": "" })
    },
    "fnServerData": function (sSource, aoData, fnCallback) {
    $.ajax({
    "dataType": 'json',
    "contentType": "application/json; charset=utf-8",
    "type": "GET",
    "url": sSource,
    "data": aoData,
    "success":
    function (data) {
    var json = JSON.parse(data.d);
    alert(json);
    fnCallback(json);
    $("#resProDataTable").show();
    }
    });
    }

            //    "ajax": {
            //        "type": "POST",
            //        "url": "/webservices/datatables.asmx/GetAllTickets",
            //        "contentType": "application/json; charset=utf-8",
            //        "dataType": "json"
            //    },
            //    "columns": [
            //         { "data": "smTicketNo" },
            //         { "data": "smEmpName" },
            //         { "data": "smStatus" },
            //         { "data": "smCustomerName" },
            //         { "data": "smProdName" },
            //         { "data": "smDateReceived" },
            //         { "data": "smWorkStartDate" },
            //         { "data": "smWorkEndDate" },
            //         { "data": "smTotalTime" },
            //         { "data": "smProblemDescription"},
            //         { "data": "smRating" }]
            });
        }); 
    

    '''

    Regards,
    Joe

  • allanallan Posts: 61,669Questions: 1Answers: 10,096 Site admin

    Hi Joe,

    You'd need to check your web-server's documentation to find out how to check its logs. I presume you are using IIS, so you might start here for example.

    Allan

  • joebabu4ujoebabu4u Posts: 7Questions: 3Answers: 0

    Hi Allan
    Server logs say the following error.

    "The server {B91D5831-B1BD-4608-8198-D72E155020F7} did not register with DCOM within the required timeout."

    I am stuck with this error. Not able to proceed further.

    My confusion is that legacy datatables are working fine. But New version 10 doesn't work.

    Regards,
    Joe

  • allanallan Posts: 61,669Questions: 1Answers: 10,096 Site admin

    I'm afraid I have no idea what that error message means. You'd need to refer to the .NET documentation or a .NET user forum for help with that.

    My confusion is that legacy datatables are working fine. But New version 10 doesn't work.

    That suggests that the server-side script hasn't been updated to use the new server-side processing parameters.

    Allan

This discussion has been closed.