Getting Ajax error while using dataTables 1.10 with C# WebServices
Getting Ajax error while using dataTables 1.10 with C# WebServices
joebabu4u
Posts: 7Questions: 3Answers: 0
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
This discussion has been closed.
Answers
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
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
In the fiddle I'm seeing this response:
You will need to look at the server logs to determine why the 404 error is being returned.
Kevin
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
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
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
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();
}
});
}
'''
Regards,
Joe
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
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
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.
That suggests that the server-side script hasn't been updated to use the new server-side processing parameters.
Allan