我是Jquery的一個大新手; 我試圖從服務器獲取一些JSON:有我的代碼:使用ajax從服務器獲取Json
$.ajax({
url: "/addemail",
type:'POST',
data: $("form#form12").serialize(),
success: function(my_json) {
// I suppose that Json returned by the addmail() is in the var: my_json ?
//inject my_json inside some <td >
}
});
我的PHP函數(使用Zend IM)
public function addemailAction(){
$data=array(array('Email'=>'[email protected]',
'Name'=>'Abc Def')
);
$this->_helper->json->sendJson($data);
}
我是新來的,請不要親切的投票。
難道你不必在那個URL中使用一些控制器嗎?你現在可以更具體地瞭解你的代碼出了什麼問題嗎? – raina77ow
不要忘記添加'dataType:'json''然後嘗試像alert(my_json.Email);''成功'內'' – Spokey
@ raina77ow:試圖讓json返回的addemail(); – mboullouz