I want get value from php file, so I call json_encode function in my php script. but when i get value using javascript the result is undefined.
I am using codeigniter and javascript.
Javascript
var sisa = (persentasevco / 100) * (jumlahvco)
document.getElementById('periodetk').value = periodetk
var totalt = sisa * periodet
$.ajax({
url: '<?=base_url(\'lahan/convertString/\')?>' + totalt,
success: function (data) {
document.getElementById('persediaanvco').value = data.hasil
},
})
PHP
public function convertString($value){
$hasil = number_format($value,2,',','.');
echo json_encode($hasil);
}
I want send $hasil from php to javascript