0
我正在向Zend控制器發出POST請求,使用ajax。Zend重定向到json響應
$.ajax({
type: 'POST',
data: data,
dataType: "json",
error: function(e){
console.log(e);
}
success: function(msg){
if(msg.success){
//doesn't reach here. I'm getting redirected
console.log('success');
}
}
});
在Zend中,我有以下行:
$this->jsonResponse(array('success' => true, 'embed' => 'some text here'));
我的問題是,我越來越重定向到JSON響應頁面(這是實際的頁面),其中包含的響應。答案是正確的,但我不想被重定向。我不知道發生了什麼,爲什麼會發生這種情況。
請提供一些更多的細節關於你的代碼。 – 2015-04-06 10:42:29
@IndrasinhBihola POST請求與JavaScript中的同一頁面與ajax。我不知道該說些什麼。 – Matei 2015-04-06 10:47:06
你爲什麼不嘗試** JSON動作助手**? :http://framework.zend.com/manual/1.12/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.json – 2015-04-06 10:49:39