jquery - Building JSON to include attributes for use in DataTables -


i've been playing jquery datatables few months , @ stage using json build tables opposed html (ridiculously quicker level of data being pulled).

due age of servers , software involved i'm using vbscript (classic asp) build json calling follows:

$().ready(function(){     $("#example").datatable({         "sscrollx": "90%",         "sscrollxinner": "100%",         "ajax":'ajax.asp?rt=test'     }); }); 

i'm building json in ajax.asp file so

response.expires=-1 requesttype=request.querystring("rt") if requesttype = "test"     ajaxsql="select * table"     set ajaxrs=myconn.execute(ajaxsql)     ajax="{ 'data': [ "     while not ajaxrs.eof         ajax=ajax&"['"&ajaxrs("column1")&"', '"&ajaxrs("column2")&"', '"&ajaxrs("column3")&"'],"         ajaxrs.movenext     loop     ajax=left(ajax,(len(ajax)-1))     ajax=ajax&" ] }"     response.write(replace(ajax,"'",""""))     ajaxrs.close     set ajaxrs=nothing     set ajaxsql=nothing end if 

i know it's far elegant seems way t o build json classic asp works.

the main problem i'm facing not above code. it's lack of attributes in cells datatables rendering. use these attributes in jquery scripts on page each cell should have it's own class can use trigger jquery event , attributes such data-key , data-value can pull use later. example be:

$(".class").on("click", function(){     var key=$(this).attr("data-key"); }); 

but don't know how can build attributes json rendered datatables plugin (by thinking has @ point of building json because attribute values directly correlate data being pulled server, such primary key).

no doubt i'm doing fundamentally wrong , grateful can point me in right direction.

thank all

elboffor

::edit:: clarify i'm after, i've written attributes in html so:

<td class="classname" data-key="123">column1data</td> 

what need know is:

  1. what json need like?

  2. what need include when calling datatable render reckognises attributes , writes in dom?

this enable me use these attributes further blocks scripts on page


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo