Going a little insane here, trying to bake my own ajax call to reach web api controller method.
Amongst many other efforts:
transport: {
read: function (options) {
$.ajax({
url: "api/FlfProd/GetSchedList/",
data: {
data: JSON.stringify(options)
},
type: 'GET',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function (data, textStatus, xhr) {
//debugger;
},
error: function (xhr, textStatus, errorThrown) {
console.log('Error in Operation');
}
});
},
parameterMap: function (options, operation) {
if (operation.toString().toLowerCase() === 'read') {
return options;
}
}
This reaches the web api, but only if I specify nothing in the controller method signature (i.e. no {} parameter in the Route).
However, when it reaches the server, the parameters are all locked in a single string such as : [0]: {[data, {"data":{"take":10,"skip":0,"page":1,"pageSize":10}}]}.
Using ordinary web service no such difficulty exists, but I want to complete moving to Web API and I frankly hate everything about MVC. Most examples such as Telerik's GridWebApiCrud are ancient and involve MVC. Plus they don't work anymore as far as I can tell.
Really pulling my hair out on this one. Is anybody out there using $.ajax methods successfully with Web API controllers? At the back end I want to use Kendo DynamicLinq as I always have, but I need to be able to bake in the skip, take, sort and filter parameters and I just can't find a way to do it. Filling a grid from Web API that doesn't do any server-side paging is not difficult at all.
Bob Graham