This is my .ctp file ajax function => this is my ajax function in which I'm assigning the id so that I can get all the order nos for this particular id and append it to the select option.
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);
}
});
}
This is my controller => Here I'm providing the id via the ajax function but not getting the response properly on ajax response
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;
}
}