I have an ajax function whose response is a html table.I need to convert it into array.
My response is like the following:
<table>
<tr>
<td>4362</td>
<td>Education</td>
</tr>
<tr>
<td>4373</td>
<td>Education world</td>
</tr>
</table>
I need to change this to following array.
[['4362','Education'],['4373','Education world']]
I have done the following ajax code but is not giving me the exact form.
success:function(hasil) {
var table_response = $.parseHTML($(hasil).filter('table').html());
console.log($(table_response).each(function(index, tr) {
$('td', tr).map(function(index, td) {
return $(td).text()
})
}));
}
I have tried another code also,but its giving me all td contents in the array
console.log($('td', table_response).map(function(_, el) {
return $(el).html()
}));