i have a code that should pass the value of all checked list to a php file , so as to delete the rows of a csv file . so the check box value is dynamic
<tr><td><span class="custom-checkbox"><input type="checkbox" class="checkbox" id="checkbox"'+count+'" name="options[]" value="'+count+'"><label for="checkbox1"></label></span></td>';
and i have to get all the value of checked checkbox , so i used javascript and this javascript will pass the value to PHP through ajax
<script type="text/javascript">
$( document ).ready(function() {
$( ".button1" ).click(function() {
var val = [];
$("input:checked").each(function (index,value) {
val[index] = this.value;
});
var myJSONText = JSON.stringify(val);
$.ajax({
data: {'kvcArray': myJSONText},
url: 'Index.php',
type: 'POST',
success: function(result) {
// alert(data);
}
});
});
});
</script>
so it has to pass the value to same page (Index.php) and PHP code is'
<?php
if (isset($_POST['kvcArray'])) {
echo "<pre>";
echo "<script>console.log('Debug Objects' );</script>";
var_dump(json_decode($_POST['kvcArray'], true));
echo "</pre>";
die();
}
?>
but it is not posting the value . till Javascript code everything works fine ( i did an alert to check the data is fetched or not ) but the value is not getting posted in PHP ,