0
我試過了一個簡單的使用jquery的ajax應用,並且錯誤是每個數據對象都是null。誰能幫我 ? 這裏的mycode的:如何在Zend Framework中使用ajax和json編碼2
protected $mysqlAdapter;
protected $studentid;
protected $fullname;
protected $birthdate;
protected $placebirth;
protected $gender;
protected $id_religion;
protected $nm_religion;
protected $stdaddr;
protected $stdphone;
protected $stdcellular;
protected $stdemail;
public function indexAction()
{
$request = $this->getRequest();
$response = $this->getResponse();
$nm_pd = $this->request->getPost('nm_pd');
$tgl_lahir = $this->request->getPost('tgl_lahir');
$id_agama = $this->request->getPost('id_agama');
$nm_agama = $this->request->getPost('nm_agama');
$dbAdapter = $this->getMysqlAdapter();
$sql = new Sql($dbAdapter);
$all = $sql->select();
$all->from('v_datadetail_feeder');
$all->where(array('studentid' => 11509002));
$statement = $sql->prepareStatementForSqlObject($all);
$result = $statement->execute();
foreach ($result as $rs) {
$studentid = $this->$rs['studentid'];
$fullname = $this->$rs['fullname'];
$birthdate = $this->$rs['birthdate'];
$placebirth = $this->$rs['placebirth'];
$gender = $this->$rs['gender'];
$id_religion = $id_agama;
$nm_religion = $nm_agama;
$stdaddr = $this->$rs['stdaddr'];
$stdphone = $this->$rs['stdphone'];
$stdcellular = $this->$rs['stdcellular'];
$stdemail = $this->$rs['stdemail'];
$data = array('fullname'=>$fullname,
'studentid'=>$studentid,
'birthdate'=>$birthdate,
'placebirth'=>$placebirth,
'gender'=>$gender,
'id_agama'=>$id_religion,
'nm_agama'=>$nm_religion,
'stdaddr'=>$stdaddr,
'stdphone'=>$stdphone,
'stdcellular'=>$stdcellular,
'stdemail'=>$stdemail,
);
$response->setContent(Json::encode($data));
}
return $response;
}
而結果: { 「全名」:空, 「studentid」:空, 「出生日期」:空, 「placebirth」:空, 「性別」:空, 「id_agama」 :空, 「nm_agama」:空, 「stdaddr」:空, 「stdphone」:空, 「stdcellular」:空, 「stdemail」:空}
如果我使用setTerminal()這將是致命的錯誤 – 2015-03-25 07:49:35
@FebryDamatrasetaFairuz什麼錯誤? – Vipul 2015-03-25 08:48:39