title: ajax post in laravel
body: <p>I know this may be a trivial question but I am just not able to get this ajax call to work..</p>
  
  <p><strong>View (html)</strong> </p>
  
  <pre><code>  &lt;div class="col-sm-6 col-xs-3 pl0" style="margin-left: -5px;"&gt;
       &lt;button class="btn btn-primary visible-xs" name="btn-callback"&gt;&lt;i class="fa fa-arrow-right" aria-hidden="true"&gt;&lt;/i&gt;&lt;/button&gt;
       &lt;button class="btn btn-primary hidden-xs" name="btnCallback" id="btnCallback"&gt;&lt;i class="fa fa-arrow-right" aria-hidden="true"&gt;&lt;/i&gt; Instant Callback
      &lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>now I am placing a click event on btnCallback button </p>
  
  <p><strong>JQuery code</strong></p>
  
  <pre><code>$('#btnCallback').click(function () {
              var phone = document.forms["frm-callback"]["callphone"].value;
              if (phone.length != 10) {
                  document.getElementById('errcallbackModal').innerHTML = "Enter 10 digit Phone number";
                  return false;
              } else if (isNaN(phone)) {
                  document.getElementById('errcallbackModal').innerHTML = "Please Enter only number";
                  return false;
              } else {
                  document.getElementById('errcallbackModal').innerHTML = "";
  
                  var randomnum = Math.floor(100000 + Math.random() * 900000)
                  randomnum = randomnum.toString().substring(0, 5);
                  var fullNumber = '0091' + phone;
  
                  url = '/ambulance/type2/sendOtp';
                  data = {
                      Code: randomnum,
                      MobNumber: fullNumber,
                  };
  
                  $.ajaxSetup({
                      headers: {
                          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                      }
                  });
  
                  console.log(fullNumber);
                  $.ajax({
                      url: url,
                      data: data,
                      type: 'POST',
                      datatype: 'JSON',
                      success: function (response) {
                          if (response.status === true) {
                              console.log(response.message);
                              $('#myModalCallback').modal('toggle');
                          } else {
                              alert('Issue');
                          }
                      },
                      error: function (response) {
                          $('#errormessage').html(response.message);
                      }
                  });
              }
          });
      &lt;/script&gt;
  </code></pre>
  
  <p><strong>web.php (routes)</strong></p>
  
  <pre><code>Route::post('/ambulance/type2/sendOtp', 'AmbulanceController@sendOtp');
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public function sendOtp()
      {
          $code = Input::get('Code');
          $mobnum = Input::get('MobNumber');
  
          //set otp code in session to verify
  //        session(['verifyOtp' =&gt; $code]);
  //        ParseCloud::run('sendcode', ["Code" =&gt; $code, 'MobNumber' =&gt; $mobnum]);
  
          return Response::json(['status' =&gt; true, 'message' =&gt; 'OTP has been sent to your mobile number']);
      }
  </code></pre>
  
  <p>It's not entering the success callback. There is some trivial mistake with the code but I am not able to figure it out.</p>
  
  <p>Any assistance will be highly appreciated.</p>