This question already has an answer here:
I have an html which contains dynamically created tables. Im adding checkbox for each rows, as follows
<table style="width: 100%" id="client_site_data" class="display">
<caption>Client Site Info</caption>
<thead>
<tr>
<th>Set to Processing</th>
<th>Sites</th>
<th>Machines</th>
<th>ProcessingState</th>
<th>Last Updated</th>
<th>Reset the Processing</th>
</tr>
</thead>
</table>
....
$.each(data, function(id, value) {
rows.push('<tr><td><input type="checkbox" id="chkbox" name="chkbox" value="'+value.site+':'+value.client+'\'"></td><td>' + id + '</td><td>' + value.machine
+ '</td><td>' + value.state + '</td><td>'
+ value.date_processed + '</td><td><button type="button" onclick="resetSite(\''+ value.site+'\',\''+value.client+'\')">Reset</td></tr>');
});
Im trying to POST the value using ajax to my backend service(which is python)
$("#chkbox").change(function () {
var value = $(this).val();
var res = value.split(":");
$.ajax({
type: "POST",
url: "http://localhost:8080/cache/setProcessing?site="+res[0]+"&client="+res[1],
/*data: {
chkbox: value
},*/
success: function (data, textStatus) {
alert('included for processing ');
},
error : function(xhr, textStatus, errorThrown) {
alert("Failed. Error : "
+ errorThrown);
}
});
});
But when i check the checkboxes in my table nothing happens. Means it is not calling my javascript function.
What im doing wrong? Also, if i select multiple rows at once, this logic is right/will work?
Aucun commentaire:
Enregistrer un commentaire