How do I use AJAX to return a variable in PHP? I am currently using echo in my controller to display a price on dropdown .change in a div called pr
echo json_encode($RESPONDE);
exit();
The exit is not to display other things except answer. RESPONDE is good to be array or object. You can access it at
success: function(data)
{ data }
data is the responde array or whatever you echo.. For example...
echo json_encode(array('some_key'=>'yesss')); exit();
at jquery
success: function(data){ alert(data.some_key); }