title: Trying to perform ajax request in Cakephp but will redirect to the link specified in the form
body: <p>I am trying to perform ajax request when a link is click passing id value. And try to alert the data if successful. Please tell me what is wrong.
      $('a.view-btn').on('click', function(e){
              var view = $(this);
              var id = view.data('id');</p>
  
  <pre><code>        $.ajax({
              url: '/bootstrap_exercise/contacts/view/',
              type: 'POST',
              data: {product_id: id},
              success: function(data) {
                  alert(data);
                  $('div#view-contact').load('/bootstrap_exercise/contacts/view .view-contact');
              }
          });
          console.log(id);
      });
  </code></pre>
  
  <p>this is my edit method in controller</p>
  
  <pre><code>public function view($id) {         
          if ($this-&gt;request-&gt;is('ajax')) {
              $this-&gt;autoRender = false;
              $this-&gt;set('contact', $this-&gt;request-&gt;data('product_id'));
              echo "AJAX SUCCESS";
          } else {
              $this-&gt;set('contact', $this-&gt;Contact-&gt;findById($id));
          }
      }
  </code></pre>