jquery - How to Insert JSON data into DataTable -



jquery - How to Insert JSON data into DataTable -

i new javascript , trying dynamically load json info datatable on button click.

my json info in below format

[{"devicename":"and1","ipaddress":"10.10.12.1221"}, {"devicename":"and2","ipaddress":"10.10.12.1222"},{"devicename":"and3","ipaddress":"10.10.12.1223"}]

here finish html code: when running code, getting uncaughttype error in processdevicedataresults @ ('#devicetable'). but, pretty sure not way load info in datatable.

//set hubs url connection var url = 'http://localhost:8080/signalr'; var connection = $.hubconnection(url); // declare proxy reference hub. var hubproxy = connection.createhubproxy('hubclass'); hubproxy.on('devicedataresults', processdevicedataresults); connection.start().done(function() { $("#getdevicedata").click(function() { hubproxy.invoke('getdevicedata'); }); }); function processdevicedataresults(results) { $('#devicetable').datatable({ "aodata": results }); }

try this

data.json

{ "data": [ { "devicename": "and1", "ipaddress": "10.10.12.1221" }, { "devicename": "and2", "ipaddress": "10.10.12.1222" }, { "devicename": "and3", "ipaddress": "10.10.12.1223" } ] }

js

$('#devicetable').datatable({ "ajax": "data.json", "columns": [ { "data": "devicename" }, { "data": "ipaddress" } ] });

example here http://www.wishesafterlive.com/stackoverflow/datatablejson.php

jquery html json

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -