parsing variable javascript ke controller

permisi suhu saya ada code seperti ini :

drilldown: function(e) {
              var month = e.point.drilldown
              console.log(month)
              var drilldown = {
                        series: []
                    };

di sini value yang di dapat seperti "January" atau "February" atau dll. hanya nama 1 bulan. pertanyaan saya di sana bagaimana cara parsing ke controller var month ? karena saya ingin ambil value nya untuk di parsing ke query lagi trima kasih

avatar Ridhoa
@Ridhoa

129 Kontribusi 33 Poin

Diperbarui 5 tahun yang lalu

1 Jawaban:

<pre>

class test extends MY_Controller { public function set() {

$input = $this-&amp;gt;input-&amp;gt;post(&#039;bulan&#039;);

echo json_encode($input);

} } </pre>

<pre>

$(document).ready(function() {

$("#send").click(function (e) { var months = new Array(12); months[0] = "January"; months[1] = "February"; months[2] = "March"; months[3] = "April"; months[4] = "May"; months[5] = "June"; months[6] = "July"; months[7] = "August"; months[8] = "September"; months[9] = "October"; months[10] = "November"; months[11] = "December";

date_trn = new Date(); nama_bulan = months[date_trn.getMonth()];

jQuery.ajax({ type: "POST", url: "&lt;?php echo base_url(); ?&gt;" + "test/set", dataType: 'json', data: {bulan: nama_bulan}, success: function(res) { console.log(res); alert(res); } }); });

)}; </pre>

avatar sanlie
@sanlie

22 Kontribusi 2 Poin

Dipost 5 tahun yang lalu

Login untuk ikut Jawaban