title: Laravel : Ajax delete with bootstrap modal dialog
body: <p>I have a bootstrap modal dialog (see image below)<img src="https://i.stack.imgur.com/rXlhu.png" alt="enter image description here"></p>
  
  <p>The red danger button (marked by xx) is where the action is happening. When that button is  clicked - the uploaded file ( in this case - 2013-09-18_16h40_47.png) should be deleted while the modal dialog box is still open which is not what is happening right now. The download id is not getting passed to the controller method <strong>and</strong> the modal dialog is closed when the red button is clicked. </p>
  
  <p>UI code : </p>
  
  <pre><code>{{ Form::open( array('route' =&gt; 'download.deletedownload','method' =&gt; 'post','id' =&gt; 'form-add-setting') ) }}
                                                                      {{Form::hidden('downloadId',$download-&gt;id)}}
                                                                      &lt;button id="downloadDelete" type="submit" class="btn btn-xs btn-danger"&gt;xx&lt;/button&gt; 
                                                                  {{Form::close()}}
  </code></pre>
  
  <p>The route looks like this </p>
  
  <pre><code>Route::post('deletedownload', array('uses' =&gt; 'DownloadsController@deletedownload', 'as'=&gt;'download.deletedownload'));
  </code></pre>
  
  <p>and the controller method look like this </p>
  
  <pre><code>public function deletedownload()
  {
      if(Request::ajax()) {
          dd("this is an ajax request");
      };
      var_dump('i am in the deletedownload method of the DownloadsController class');
      $id = Input::get('id');
      dd($id);
      return Redirect::back();
  }
  </code></pre>
  
  <p>Javascript : </p>
  
  <pre><code>   $('#downloadDelete').click(function (e)
      {
  
          $.ajax({
              type: 'POST',
              url: '&lt;?=URL::to('/')?&gt;/deletedownload',
              data: 'dataString',
              dataType:'json',
              success: function(result)
              {
                 console.log(result);
              }
          })
  
      });
  </code></pre>
  
  <p>and this is the output </p>
  
  <pre><code>string(66) "i am in the deletedownload method of the DownloadsController class" NULL
  </code></pre>
  
  <p>Notice that "this is an ajax request" is not getting echoed. Hence i have reasons to believe that is not an ajax request. </p>
  
  <p>Any help would be well appreciated. </p>
  
  <p>thanks</p>