<?php
public function btneditAction() {
$data['id'] = $this->request->getPost('id');
$data['uname'] = $this->request->getPost('uname');
$data['basesalary'] = $this->request->getPost('basesalary');
$data['travelfee'] = $this->request->getPost('travelfee');
$data['overtime'] = $this->request->getPost('overtime');
$data['ssc_emp'] = $this->request->getPost('ssc_emp');
$data['ssc_comp'] = $this->request->getPost('ssc_comp');
$Salarydetail = new SalaryMaster();
$pont=$Salarydetail->btnedit($data);
echo json_encode($pont);
$this->view->disable();
}
?>
It shows in network is like this
{"valid":true} //when true {"valid":false} //when false
I want to that valid value ,but when i alert ,it shows undefined only?
BtnEdit : function(val){
var form=$('#edit_salary');
$.ajax({
type:'POST',
data: form.serialize(),
dataType:'json',
url : "btnedit",
success:function(d){
alert(d.valid); //undefined
alert(d); //{"valid":true}
}
});
}
Use JSON.parse
to transform the string in an Object:
success:function(d){
d = JSON.parse(d);
alert(d.valid); // true
}
You need to use JSON.parse
to transform the string in an Object:
Try
success:function(d){
d = JSON.parse(d);
alert(d.valid);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With