title: CakePhp 2.x print sql query On Ajax Request
body: <p>I am trying to print the mysql query on Ajax Request but it is not showing .</p>
  
  <p>My View Page </p>
  
  <p><a href="https://i.stack.imgur.com/vnd0k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vnd0k.png" alt="enter image description here"></a></p>
  
  <p>Clicking the Search button will call one Ajax Function </p>
  
  <p>Ajax.js</p>
  
  <pre><code>$(document).ready(function(){
  
  function random_number()
  {
      return Math.floor(Math.random() * 255);
  }
  $("#btningSrch").click(function(){
      $("#rpts").html("&lt;img src='https://xx.xx.xx.xx/project/img/ajaxLoader1.gif' /&gt;");
      alert("hi");
      $.ajax({
             type: "GET",
             url: "https://xx.xx.xx.xx/project/controller/view/"+random_number(),
             data: "startDate="+$("#startDate").val()+"&amp;type="+$("#type").val()+"&amp;orderby="+$("#orderby").val(),
             dataType: "html",
             success: function(msg){      
                  alert(msg);
                  $("#rpts").html(msg);
             }
           });
      return false;
    });
  });
  </code></pre>
  
  <p>Controller.php</p>
  
  <pre><code>function show_in_summary()
  {
      $this-&gt;isLoggedIn();
      //pr($this-&gt;request); exit;
      //echo $this-&gt;request-&gt;is('ajax');
      if ($this-&gt;request-&gt;is('ajax'))
      {
          //echo 2222; exit; //$this-&gt;layout = 'index3';
          //pr($this-&gt;InTrafficSummary-&gt;txtChk($this-&gt;params['url']['startDate']));
          //die();
          //pr($this-&gt;request-&gt;query);exit;
          //if ($this-&gt;InTrafficSummary-&gt;txtChk($this-&gt;request-&gt;query['startDate']))
          //{
              $this-&gt;set('record',1);
              $this-&gt;loadModel('InOutTrafficSummary');
              $data = $this-&gt;InOutTrafficSummary-&gt;readInBoundTrafficSummary($this-&gt;request-&gt;query['startDate'],
              $this-&gt;request-&gt;query['type'],$this-&gt;request-&gt;query['orderby']);
              $this-&gt;set('reports',$data[0]);
              $this-&gt;set('total',$data[1]);
              $this-&gt;set('date',date("Y-m-d",strtotime($this-&gt;request-&gt;query['startDate'])));
              $this-&gt;set('type',$this-&gt;request-&gt;query['type']);
          //}
          //else
          //{
              //$this-&gt;set('reports',array());
              //$this-&gt;set('record',0);   
              //$this-&gt;set('total',array());
              //$this-&gt;set('date',date("Y-m-d",strtotime($this-&gt;params['url']['startDate'])));
              //$this-&gt;set('type',$this-&gt;params['url']['type']);
          //}
      }
  }               
  </code></pre>
  
  <p>Model.php</p>
  
  <pre><code>$rs = $this-&gt;find('all', array('joins' =&gt; array(array(
      'table' =&gt; 'InOutTrafficSummary',
      'alias' =&gt; 'Carriers',
      'type' =&gt; 'INNER',
      'conditions' =&gt; array(
       'Carriers.CarrierId = '.$useTable.'.FK_IngressCarrierId'))),
      'conditions' =&gt; array('InDate' =&gt; date("Y-m-d",strtotime("-1 days"))),
      'fields' =&gt; array(
  'FK_IngressCarrierId,CarrierName,Sum(TotalCalls),Sum(ConnectedCalls),sum(Duration),(Sum(ConnectedCalls)/Sum(TotalCalls))*100,sum(Duration)/Sum(ConnectedCalls),sum(SaleAmount)'),'group' =&gt; 'FK_IngressCarrierId','order' =&gt; 'sum(Duration) DESC'));
  
  echo $this-&gt;element('sql_dump'); exit;
  </code></pre>
  
  <p>I want to print the query above as it is not showing any records , i am  assuming there is a mistake in the formation so need to view the entire query.All the other things are working fine. </p>
  
  <p>I am a newbie to CakePHP. </p>