[請益] Zend的Ajax (Smarty)
我是用Zend framework去做架構,
用Smarty做View的部份(關了Zend預設),
但用jQuery去發送,這部份就不知道怎回傳,
-Controller-
if($this->_request->isPost()){
$input = $this->getRequest()->getPost('input');
}
-jQuery-
$(document).ready(function(){
$('#login').click(function(){
var link = this;
$.ajax({
type: 'post',
url: link.href + '/openid',
async: false,
dataType: 'json',
data: {input:$('#input').val()},
success: function(response){
$('#show').show('slow').html(response.state);
},
error: function(xhr){
$('#show').html(xhr.error);
}
});
});
});
有看到Wacow的方式是直接用
$this->view->error = $error;
$this->view->messages = $messenger->getMessages();
就可用Json的方式傳回
請大大解惑了...
推
05/14 01:40, , 1F
05/14 01:40, 1F
→
05/14 01:41, , 2F
05/14 01:41, 2F
→
05/14 01:43, , 3F
05/14 01:43, 3F
是有用這樣方式:
$a['state'] = $input;
$json = Zend_Json::encode($a);
echo $json;
不過也是收到error的回覆
※ 編輯: j87b0003 來自: 59.104.173.51 (05/14 02:07)
推
05/14 02:06, , 4F
05/14 02:06, 4F
→
05/14 02:09, , 5F
05/14 02:09, 5F
推
05/14 02:29, , 6F
05/14 02:29, 6F
→
05/14 02:30, , 7F
05/14 02:30, 7F
→
05/14 02:47, , 8F
05/14 02:47, 8F
推
05/14 03:17, , 9F
05/14 03:17, 9F
→
05/14 03:18, , 10F
05/14 03:18, 10F
→
05/14 03:18, , 11F
05/14 03:18, 11F
推
05/14 10:09, , 12F
05/14 10:09, 12F
→
05/14 10:10, , 13F
05/14 10:10, 13F
→
05/14 10:11, , 14F
05/14 10:11, 14F
→
05/14 10:11, , 15F
05/14 10:11, 15F
→
05/14 10:12, , 16F
05/14 10:12, 16F
→
05/14 10:13, , 17F
05/14 10:13, 17F
→
05/14 10:14, , 18F
05/14 10:14, 18F
推
05/14 12:58, , 19F
05/14 12:58, 19F
推
05/14 13:04, , 20F
05/14 13:04, 20F
→
05/14 13:05, , 21F
05/14 13:05, 21F
→
05/14 13:05, , 22F
05/14 13:05, 22F
推
05/20 09:49, , 23F
05/20 09:49, 23F
→
05/20 09:50, , 24F
05/20 09:50, 24F
→
05/20 09:51, , 25F
05/20 09:51, 25F