I have an HTML Table and I am retrieving the data (using Jquery function) from the specific <td>
VALUES and pass the data to another java server page using Ajax.
This is the table <tr>
<tr height=40 style='mso-height-source:userset;height:30.0pt'>
**<td class=xl86 style='border-left:none' contenteditable="true"> </td>
<td class=xl86 style='border-left:none' contenteditable="true"> </td>
<td class=xl86 style='border-left:none'contenteditable="true" > </td>
<td class=xl86 style='border-left:none'contenteditable="true"> </td>**
</tr>
I code a jQuery function for retrieving these table values individually that is below.
$(document).ready(function () {
var col1=" ";
var col2=" ";
var col3=" ";
var col4=" ";
$('#btn_read_HTML_Table').click(function () {
$('#mytable tbody>tr').each(function () {
var currentRow=$(this).closest("tr");
col1=currentRow.find("td:eq(0)").text();
col2=currentRow.find("td:eq(1)").text();
col3=currentRow.find("td:eq(2)").text();
col4=currentRow.find("td:eq(3)").text();
var data1=col1+"\n"+col2+"\n"+col3+"\n"+col4;
});
$.ajax({
url: "load_tabledata.jsp",
type:'POST',
data:{c1: col1,c2:col2,c3:col3,c4:col4},
success: function (data, textStatus, jqXHR) {
console.log(data);
}
})
});
});
Problem is Ajax taking empty value of var col,col2,col3 and col4 but inside function table values retrieving.
I want to get these retrieved values in my ajax function so that I could pass these values inside the data.