title: How to resolve "ajax 403 error forbidden in CAKEPHP 2.x"
body: <p>i'm trying to access data using ajax call in cakephp but getting 403 forbidden error, given below.</p>
  
  <pre><code>GET http://localhost/ec/bazar/Products/color_switcher/3 
  403 (Forbidden)
  jquery.js:6 
  x.ajaxTransport.sendjquery.js:6 
  x.extend.ajax53:251 
  colorSwitcher53:327 
  onclick
  </code></pre>
  
  <p>i'm using this code to make call</p>
  
  <pre><code>function colorSwitcher(id){
  
          var testid = id;
         $.ajax({
                  type: 'GET',
                  url: '&lt;?php echo $this-&gt;webroot; ?&gt;Products/color_switcher/' + testid,
                  error: function () {
                      console.log("error in ajax call");
                  },
                  success: function (data) {
                      $("#img-portion").html(data);
                  },
              });
  
      }
  </code></pre>
  
  <p>controller</p>
  
  <pre><code>public function color_switcher($testid = ''){
        $this-&gt;layout= 'ajax';
  }
  </code></pre>
  
  <p>color_switcher.ctp</p>
  
  <pre><code>&lt;?php echo "helooooooo"; ?&gt;  
  </code></pre>