title: Update resource AJAX Laravel 5
body: <p>I'm getting stuck with Ajax, i dont know why my ajax call returns error everytime.
  My update method dont even detect an ajax request. I've never done ajax before, but i understand the logic behind it so excuse my ignorance if i ask for dumb things lol..</p>
  
  <pre><code>  Route::post('edit/organisation/{id}',['uses' =&gt; 'OrganisationsController@update', 'as' =&gt; 'admin.organisation.update']);
  </code></pre>
  
  <p>Here is my controller method : </p>
  
  <pre><code> public function update($route = null, $id, \Illuminate\Http\Request $request)
      {
          $org = Organisation::find($id)-&gt;first();
          if($request-&gt;ajax())
          {
              dd('OK ITS AJAX');
  
          }
          if($org-&gt;update($request-&gt;all()))
          {
              //return redirect('admin/dashboard');
              return redirect()-&gt;back();
          }
      }
  </code></pre>
  
  <p>And here is my ajax</p>
  
  <pre><code>$(document).ready(function()
  {
  var form = $('.update_ajax');
  form.bind('submit',function()
  {
  
      $.ajax({
         type: form.attr('method'),
          url: form.attr('action'),
          data: form.serialize(),
          success: function(data)
          {
              alert(data);
          },
          error: function(data)
          {
              console.log('error');
          }
      });
  
  });
  });
  </code></pre>
  
  <p>And here is my HTML</p>
  
  <pre><code>  {!! Form::model($org,['route' =&gt; ['admin.organisation.update',Route::input('name'), $org-&gt;id],'class' =&gt; 'update_ajax' ]) !!}
  
  
              {!! Form::label('name','Nom') !!}
              {!! Form::text('org_name',null,['class'=&gt; 'form-control'])!!}
              {!! Form::label('org_type','Type') !!}
              {!! Form::text('org_type',null,['class'=&gt; 'form-control'])!!}
              {!! Form::label('siren','Numéro de SIREN') !!}
              {!! Form::text('org_siren',null,['class'=&gt; 'form-control']) !!}
  
              {!! Form::label('org_ape_naf','Numéro APE NAF') !!}
              {!! Form::text('org_ape_naf',null,['class'=&gt; 'form-control']) !!}
              {!! Form::submit('Appliquer',['class' =&gt; 'submit-data-btn']) !!}
  
  
              {!! Form::close() !!}
  </code></pre>