Problem with Server Side Processing

Problem with Server Side Processing

dkhandekardkhandekar Posts: 1Questions: 0Answers: 0

I am using Datatables version 1.10.5 (latest). Trying to call a simple Hello World web api.
* I have tested my end point independent of datatables and it is working fine.
* Even the JQuery ajax is working fine.

But when I tried to use it through datatables initialization
1. I do not see any network activity indicating my web api is called.
1. There are no console errors as well.
1. Table does not get initialized.

My datatable code is as follows.

function displayTable(dataJsonObject) {
            var jQuery = $("#resultTable");
            console.log(jQuery);

            var table = jQuery.DataTable({
                "processing": true,
                "serverSide": true,
                "ajax":
                {
                    "url": "@Url.RouteUrl("DefaultApi", new {httproute = "", controller = "Foo", action = "Bar"})", 
                    "type": "POST",
                    "data": dataJsonObject
                },
                "columns":
                [
                    null,
                    { "data": "ItemCode" },
                    null,
                    null,
                    null,
                    { "width": "2%" },
                    { "width": "2%" },
                    { "width": "2%" },
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    { "width": "2%" }
                ]
            }); 

dataJsonObject is set as follows:

$(document).ready(function() {
            $("a.test").on("click", function() {
               var test = "My Name"
                var searchJSON = {};
                if (dsdvendor != null) {
                    searchJSON.dsdvendor = dsdvendor;
                }
                //test(searchJSON);
                displayTable(searchJSON);
            });
        });

My simple Web Api is as follows

[AllowAnonymous]
public class FooController : ApiController
{
     [HttpPost]
      public HttpResponseMessage Bar([FromBody]string name)
        {
            var stringBuilder = new StringBuilder("Hello World ");
             stringBuilder.Append(name);
            return Request.CreateResponse(HttpStatusCode.OK, "Hello World");
        }
}

Any help is certainly appreciated. Thank you in advance.

This discussion has been closed.