Get jQuery object from table row click
The selector $('thead &gt; tr th') is not specific enough, if you have multiple tables in the page.  You want the headings of the same table that was clicked: $(this).closest('table').find('thead &gt; tr th').

var array is an unsatisfying name.  I can see that it's an array — but what does it do?  How about calling it tableHeadings?

You formed tableData using Array.map(); why not do the headings the same way?

var tableHeadings = $(this).closest('table')
                           .find('thead &gt; tr th')
                           .map(function() {
    return $(this).text();
}).get();