Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 26, 2012 02:10 PM by WindKnot
Member
24 Points
10 Posts
Nov 24, 2012 10:10 PM|LINK
I am having problems getting data back from an api controller and consuming it with a jQuery datatable (http://datatables.net/index). Has anyone done this successfully?
Star
12171 Points
1824 Posts
Nov 25, 2012 10:20 AM|LINK
You can take idea from following:
Web API(PhonesController):
public dynamic GetPhoneNumbers() { return Json(new { aaData = new[] { new [] { "Trident", "Internet Explorer 4.0", "Win 95+", "4", "X" }, new [] { "Gecko", "Firefox 1.5", "Win 98+ / OSX.2+", "1.8", "A" }, new [] { "Webkit", "iPod Touch / iPhone", "iPod", "420.1", "A" } } }, JsonRequestBehavior.AllowGet); }
jQuery:
$(function () { $('#example').dataTable({ bProcessing: true, sAjaxSource: 'api/phones/' }); });
Nov 26, 2012 02:10 PM|LINK
thanks urenjoy - it was mainly a bundles issue.
WindKnot
Member
24 Points
10 Posts
Retrieving data for a jQuery Datatable
Nov 24, 2012 10:10 PM|LINK
I am having problems getting data back from an api controller and consuming it with a jQuery datatable (http://datatables.net/index). Has anyone done this successfully?
urenjoy
Star
12171 Points
1824 Posts
Re: Retrieving data for a jQuery Datatable
Nov 25, 2012 10:20 AM|LINK
You can take idea from following:
Web API(PhonesController):
public dynamic GetPhoneNumbers() { return Json(new { aaData = new[] { new [] { "Trident", "Internet Explorer 4.0", "Win 95+", "4", "X" }, new [] { "Gecko", "Firefox 1.5", "Win 98+ / OSX.2+", "1.8", "A" }, new [] { "Webkit", "iPod Touch / iPhone", "iPod", "420.1", "A" } } }, JsonRequestBehavior.AllowGet); }jQuery:
$(function () { $('#example').dataTable({ bProcessing: true, sAjaxSource: 'api/phones/' }); });WindKnot
Member
24 Points
10 Posts
Re: Retrieving data for a jQuery Datatable
Nov 26, 2012 02:10 PM|LINK
thanks urenjoy - it was mainly a bundles issue.