我想从我通过ajax函数提供的id中获取订单号,但未成功显示值:function(response)

问题描述 投票:0回答:1

这是我的.ctp文件ajax函数=>这是我的ajax函数,在其中分配ID,以便可以获取此特定ID的所有订单号并将其附加到select选项。

function getOrderNum(id){
            $.ajax({
                type:"get",
                url: "/CustomerProblems/getOrders",                  
                data:"id="+id,
                // dataType:"json",
                success:function(response){
                    // $(".order").html("<option value="+response+">"+response+"</option>");                    
                    alert(response);
                    // console.log(response);
                }
            });
        }

这是我的控制器=>在这里,我通过ajax函数提供了id,但没有在ajax响应上正确获得响应]]

public function getOrders($id){
        $this->render(false);
        if($this->request->is('get')){
            $order_no = $this->CustomerProblems->Orders->find('all')->where(['Orders.customer_id'=>$id])->extract('order_no');
            $this->set("order_no", $order_no);    
            // pr($customers->toArray());die;
            echo json_encode($customers);
            // echo $customers;
            // die;
        }
    }
    

这是我的.ctp文件ajax函数=>这是我的ajax函数,我在其中分配ID,以便可以获取此特定ID的所有订单号并将其附加到select选项。函数...

jquery ajax cakephp-3.0
1个回答
0
投票

当您使用get方法时,您可以尝试在数据中传递对象参数,也可以尝试设置内容类型

© www.soinside.com 2019 - 2024. All rights reserved.