我正在将来自 knockout.js 页面的数据发布到 cakephp 中的控制器,它说数据已成功发布,但是,我的控制器似乎没有响应并且我没有收到警报……甚至没有空响应。我什至检查了 chrome 中的网络选项卡,它显示了正确的数据正在发布
这是从我的淘汰视图模型文件中发布的数据
var JSON_order = JSON.stringify({"orderInfo":[{"itemNumber":"1","quantity":"1","price":1.00,"productName":"test"}]});
$.post("/orders/submit_order", JSON_order,
function(data){
alert(data.check); //alert doesn't appear
}, "json");
这是我的控制器
function submit_order(){
$this->layout = false;
$this->autoRender = false;
if ($this->request->is('post')) {
$order = $this->request->data;
$order = json_decode($order, true);
$finalize_order = new submit;
$finalize_order->display_submitted_order_success($order);
}
}
这是 display_submitted_order_success 的代码(我也在 CakePHP 之外的一个 php 文件上试过这个,但它也没有工作)
function display_submitted_order_success($order = null){
$this->layout = false;
$this->autoRender = false;
//I'm just trying to display the order as-is so that I know it's even being posted to begin with
echo json_encode(array("check" => "success","order_num" => $order)); //the values passed the price check, display the result
}