I'm running into a problem with implementing a jQuery bootgrid into my ASP.Net Webforms application.
I get the following problem on my page load which prevents the bootgrid from loading data:
Uncaught SyntaxError: Unexpected token < in JSON at position 4
at Function.parse [as parseJSON] ()
at Object.success (jquery.bootgrid.js:232)
at fire (jquery-3.1.1.js:3305)
at Object.fireWith [as resolveWith] (jquery-3.1.1.js:3435)
at done (jquery-3.1.1.js:9242)
at XMLHttpRequest.
This is my bootgrid implementation in the JavaScript:
$("#grid").bootgrid({
ajax: true,
url: "/Secure/Maintenance/Roles.aspx/GetData",
rowCount: [10, 50, 75, 100, 200, -1]
})
And then here is my C# WebMethod
:
[WebMethod]
public static string GetData()
{
var results = (from x in EFDB.AspNetRoles
select x).AsQueryable();
return JsonConvert.SerializeObject(results);
}
I've used a LINQ Query to get the data and tried converting it to JSON but I'm not sure if I'm doing it correctly. When I set breakpoints in the GetData
method, none of them get reached. So I'm really having trouble debugging this.
Any advice on what I could be doing wrong?
Thanks!