title: Ajax select list
body: <p>I want to retrive the result of this kind of data list with CakePHP 3</p>
  
  <pre><code>&lt;?= $this-&gt;Form-&gt;select('notif_message', 
      [ 'oui' =&gt; 'oui', 'non' =&gt; 'non'], array('id' =&gt; 'notifmess')); ?&gt;
  &lt;?= $this-&gt;Form-&gt;hidden('notifmessage', ['value' =&gt; $notif_message]) ;?&gt;
  </code></pre>
  
  <p>The goal is when a user chosse a value, an Ajax call to this controller be done</p>
  
  <pre><code>public function notifmessage() // mise à jour des paramètres de notifications 0  = non, 1 = oui
  {
  
      if ($this-&gt;request-&gt;is('ajax')) {
  
      $notifmessage = $this-&gt;request-&gt;data('notifmessage');
  
      if($notifmessage == 'oui')
      {
          $new_notif_message = 'non';
      }
      else
      {
           $new_notif_message = 'oui';
      }
  
      $query = $this-&gt;Settings-&gt;query()
                          -&gt;update()
                          -&gt;set(['notif_message' =&gt; $new_notif_message])
                          -&gt;where(['user_id' =&gt; $this-&gt;Auth-&gt;user('username') ])                            
                          -&gt;execute();
  
      $this-&gt;response-&gt;body($new_notif_message);
      return $this-&gt;response;
  
      }
  }
  </code></pre>
  
  <p>And i would like to do this call in Ajax without reloading , i have this script</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function() {
      $('.notif_message').change(function(){
          $.ajax({
              type: 'POST',
              url: '/settings-notif_message',
              data: 'select.notif_message' + val,
              success: function(data) {
                  alert('ok');
              },
              error: function(data) {
                  alert('fail');
              }
          });
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>he doesn't work, nothing happend but i don't know why, i don't have any message in log, i can't debug without indication what doesn't not work</p>
  
  <p>Thanks</p>