මේ තියෙන්නේ Ajax එක
<script>
$(function() {
$.post(url, data, function(res) {
console.log(res);
console.log(res.stat);
console.log(res.finalID);
},' json ');
});
</script>
මේකයි call karana කරන function එක
public function TestJson() {
echo 'inside test json function<br>';
$res['stat'] = true;
$res['finalID'] = 45;
echo json_encode($res);
}
ඔය console.log කරල තියෙන දෙකම undefinned කියල එන්නේ ,ඒත් function එකෙන් හරියට echo වෙනවා {"stat":true,"finalID":45}
rep denawa 4+ bump 1k වත් දාපල්ලා
<script>
$(function() {
$.post(url, data, function(res) {
console.log(res);
console.log(res.stat);
console.log(res.finalID);
},' json ');
});
</script>
මේකයි call karana කරන function එක
public function TestJson() {
echo 'inside test json function<br>';
$res['stat'] = true;
$res['finalID'] = 45;
echo json_encode($res);
}
ඔය console.log කරල තියෙන දෙකම undefinned කියල එන්නේ ,ඒත් function එකෙන් හරියට echo වෙනවා {"stat":true,"finalID":45}
rep denawa 4+ bump 1k වත් දාපල්ලා
Last edited:
