i am trying to send javascript array to CI controller but the array is NULL i tried strigify too but still the output array is null help me with this please.
this is script
<script type="text/javascript">
$(document).ready(function(){
$('#button').click(function(){
var TableData = new Array();
$('#sampleTbl tr').each(function(row, tr){
TableData[row]={
"Day" : $(tr).find('td:eq(0)').text(),
"A" :$(tr).find('td:eq(1)').text(),
"B" : $(tr).find('td:eq(2)').text(),
"C" : $(tr).find('td:eq(3)').text()
}
});
TableData.shift();
var fullname = $('#fullname').val();
console.log(TableData);
console.log(fullname);
var arr = JSON.strigify(TableData);
$.ajax({
url: '<?php echo base_url('site/ajax');?>',
type: 'POST',
datatype: 'json',
data: {arr: arr},
success: function(){
}
});
});
});
</script>
this is the form
<form action="<?php echo base_url()?>site/ajax" method="post">
<input type="text" id="fullname" name="fullname">
<input type="submit" name="button" id="button" value="button">
<table id="sampleTbl">
<tr>
<th>Days</th>
<th>coloum A</th>
<th>coloum B</th>
<th>coloum C</th>
</tr>
<tr>
<td>Sunday</td>
<td>sunday a</td>
<td>sunday b</td>
<td>sunday c</td>
</tr>
<tr>
<td>Monday</td>
<td>monday a</td>
<td>monday b</td>
<td>monday c</td>
</tr>
<tr>
<td>Tuesday</td>
<td>tuesday a</td>
<td>tuesday b</td>
<td>tuesday c</td>
</tr>
<tr>
<td>Wednesday</td>
<td>wednesday a</td>
<td>wednesday b</td>
<td>wednesday c</td>
</tr>
<tr>
<td>tdursday</td>
<td>tdursday a</td>
<td>tdursday b</td>
<td>tdursday c</td>
</tr>
<tr>
<td>Friday</td>
<td>friday a</td>
<td>friday b</td>
<td>friday c</td>
</tr>
<tr>
<td>Saturday</td>
<td>saturday a</td>
<td>saturday b</td>
<td>saturday c</td>
</tr>
</table>
</form>
this is the controller part
public function ajax(){
$fullname = $this->input->post('fullname');
$arr = $this->input->post('arr');
$array = json_decode($arr);
echo "<pre>";
echo $fullname;
echo "<br>";
print_r($array);
// var_dump($_POST);
}