mlotfi Posted December 12, 2014 Share Posted December 12, 2014 Hi, I have server side data that populate a datatable, I stack when trying to pass array data from html page to jquery to fill the detail, as you can see in this fiddle, the detail is hard coded : http://jsfiddle.net/mlotfi/c918of1t/ I am looking for a way to send an array to that format function. Thanks, your help is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/293062-how-to-pass-array-from-html-to-jquery/ Share on other sites More sharing options...
requinix Posted December 13, 2014 Share Posted December 13, 2014 Where is the array? It has to be somewhere in the HTML or in the Javascript (or retrieved from the server through AJAX). Quote Link to comment https://forums.phpfreaks.com/topic/293062-how-to-pass-array-from-html-to-jquery/#findComment-1499465 Share on other sites More sharing options...
kicken Posted December 13, 2014 Share Posted December 13, 2014 tr.find('td').first().data('agencies') will get your json encoded array out of the data attribute on the first TD element. So long as it's valid JSON jQuery will automatically decode it into an array so you can pass it to your format function. // Open this row var agencies = tr.find('td').first().data('agencies'); var html = format(agencies); row.child(html).show(); tr.addClass('shown'); Quote Link to comment https://forums.phpfreaks.com/topic/293062-how-to-pass-array-from-html-to-jquery/#findComment-1499513 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.