title: ajax data is getting null in controller function of MVC
body: <p>I am beginner to ajax and MVC framework. I have to find mobile exist or not using ajax. I have tried following code.</p>
  
  <p><strong>View</strong></p>
  
  <pre><code>if(mno.match(phoneno)){
  //alert(mno);
   $.ajax({
                url: "/api/sales/existmobile",
                type:"POST",
                //ContentType: 'application/json',
               // dataType: "json",
                //async: false,
                //data:{'data': mno},
                //data:{data: JSON.stringify(mno)},
                data:{data: JSON.stringify(6547655566)},
                success: function (data, textStatus, jqXHR) {
                   console.log('success',data);
                      if(data === false){
                      alert('Mobile number already exists!');
                      $( "#custmobilenumber" ).focus();
                      }              
                },  
                error: function (jqXHR, textStatus, errorThrown) {
                    console.log(textStatus);
                }
          });
  }  
  </code></pre>
  
  <p><strong>Route</strong></p>
  
  <pre><code>case "sales/existmobile":
              $sale = new Sale($data);
              $result = $sale-&gt;checkMobileExistSale($result);
              break;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public function checkMobileExistSale($result)
      {
          print_r($this-&gt;data);
          // $custMdl = new CustomerModel();
          //  $mobileExistResult = $custMdl-&gt;checkMobileExist($this-&gt;data);
          // return $mobileExistResult;
      }
  </code></pre>
  
  <p><strong>Model</strong></p>
  
  <pre><code>public function checkMobileExist($mobile){
          $sql          = 'SELECT * FROM customers WHERE mobile= :mobile';
          $placeholders = [':mobile'=&gt;$mobile];
          $users = $this-&gt;select($sql, $placeholders);
          if (count($users) &gt; 0) {
              return false;
          } else {
              return true;
          }
      }
  </code></pre>
  
  <p>When I print data of ajax passed in controller then its coming null. In inspect's Network(XHR)->Headers->form data, I can see data passed from ajax. But Network(XHR)->Response, its showing null.</p>
  
  <p>I debugged with every possible way i could find with stackoverflow anwsers and google search but no use. I am not getting where the code is going wrong. </p>
  
  <p>Please help and guide. Thanks in advance.</p>