I am working in CakePHP to pass data via ajax. The data enter into the database successfully. This means the data pases from the view to the controller fine. However, it never populated the #target div. I have tried to even manually set the $data in the controller, but it still did not work. Here is my controller
<?php
App::uses('AppController', 'Controller');
class GenreselectsController extends AppController {
public $components = array('RequestHandler');
public $helpers = array('Js' => array('Jquery'));
// single search function
public function index() {
$this->loadModel('Notification');
if( $this->request->is('ajax') ) {
$this->autoRender = false;
$this->Notification->create();
$this->Notification->save($this->request->data);
$data = $this->request->data['Notification']['message'];
}
}
}
Here is my ajax
<script>
$(document).ready(function() {
$('#genresearch').change(function() {
var selectedValue = $('#genresearch').val();
var targeturl = '/genreselects/index/';
$.ajax({
dataType: "html",
type: "POST",
url: targeturl,
async : true,
data:{message:selectedValue},
evalScripts: true,
complete: function(data) {
//alert("hi neal"+selectedValue);
$("#target").append(data);
}
});
});
});
</script>
Here is my view div
<div id="target"></div>
What iam i doing wrong