Jump to content

How to pass array from html to jquery ?


mlotfi

Recommended Posts

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 :
 
 
I am looking for a way to send an array to that format function.
 
Thanks, your help is appreciated.
 

 

Link to comment
https://forums.phpfreaks.com/topic/293062-how-to-pass-array-from-html-to-jquery/
Share on other sites

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');

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.