I am currently using AJAX to retrieve and display data in my table. However, I want to capture the actual value from the selected cell in the table.
To better display user needs, I have split the returned value to obtain specific items.
Below is the script I am using within the ready event:
$(document).ready(function () {
$.ajax({
url: '/Home/getData',
type: 'GET',
beforeSend: function () {
},
dataType: 'json',
success: function (data) {
var row = '';
$.each(data, function (i, item) {
row += '<tr><td style="display:none;" >' + (item.nameInfo).split("+")[0] + '</td><td>' + (item.nameInfo).split("+")[1]
+ '</td><td>' + (item.nameInfo).split("+")[2]
+ '</td><td>' + (item.nameInfo).split("+")[2]
+ '</td></tr>'
});
$('#table1 tbody').html(row); // override previous results
},
complete: function (data) {
},
error: function (jqXhr, textStatus, errorThrown) {
alert(errorThrown);
}
});
});
The contents of the nameInfo column are as follows, and I aim to capture the full details when a user clicks on a cell:
+---------------------+
| nameInfo |
+---------------------+
| juan+25+male |
| nina+14+female |
| zeb+20+male |
+---------------------+
Any suggestions or feedback would be greatly appreciated. Thanks in advance.