I've this for append elements from json:
$.ajax({
type: "POST",
url: action,
data: dataSearch,
success: function (response) {
if (response[0].success == "success") {
$.each(response, function (index, record) {
var row = $("<tr />");
$("<td />").text(record.clavemat).appendTo(row);
$("<td />").text(record.tipomat).appendTo(row);
$("<td />").text(record.titulomat).appendTo(row);
$("<td />").text(record.autormat).appendTo(row);
$("<td />").text(record.editmat).appendTo(row);
$("<td />").text(record.edicmat).appendTo(row);
//Append checkbox to each row
row.addClass("alt");
row.appendTo(".resultsSearch");
});
} else {
alert("Data not found");
}
}
});
return false;
And I want append checkbox for each row at last column, and I dont know Thanks!
Have you tried?:
$("<td />").html('<input type="checkbox"/>').appendTo(row);
And by the way, are you sure that POST is the best choice if you are GETing information from the server? or are you changing the status of the server when you do the request? If it is not the case, check When to use Post or Get
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With