I am stuck with this problem all day. What I'm trying to do is send 2 values ββfrom the view to the controller using Ajax. This is my code in the view hot_products
:
<script>
$(function(){
$('#btnSubmit').click(function() {
var from = $('#from').val();
var to = $('#to').val();
alert(from+" "+to);
$.ajax({
url: "/orders/hot_products",
type: 'POST',
data: {"start_time": from, "end_time": to,
success: function(data){
alert("success");
}
}
});
});
});
and my hot_products controller:
public function hot_products()
{
if( $this->request->is('ajax') ) {
$this->autoRender = false;
}
}
I don't know how to get 2 values ββwhich are start_time and end_time. Please help me. Thank you in advance. PS: im using cakephp 2.3
source
share