title: Laravel Ajax Call to Controller
body: <p>I am pretty new with <code>Laravel</code> and I am having an issue with accessing a specific method in my <code>Controller</code>. I am trying to change a Database value (language) based on a dropdown menu.</p>
  
  <p><strong>settings.profile.blade</strong></p>
  
  <pre><code>&lt;select id="accountLanguage" class="form-control" method="GET"&gt;
      &lt;option value="en" {{ ($strLanguage == 'en') ? 'selected = "selected"' : "" }} &gt;English&lt;/option&gt;
      &lt;option value="es" {{ ($strLanguage == 'es') ? 'selected = "selected"' : "" }} &gt;Español&lt;/option&gt;
      &lt;option value="he" {{ ($strLanguage == 'fr') ? 'selected = "selected"' : "" }} &gt;French&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p><strong>ProfileController</strong></p>
  
  <pre><code>public function index() {
  
      $objUser = Auth::User();
  
      $strLanguage = $objUser-&gt;lang;
  
      return view("application.settings.profile",[
          'objUser' =&gt; $objUser,
          'strLanguage' =&gt; $strLanguage
      ]); 
  
  }   
  
  // THE METHOD I NEED ACCESS TO
  function update( $strLang ) { 
  
      $objUser = Auth::User();
  
      // UPDATE LANGUAGE
      $bolUpdated = $objUser-&gt;updateLanguage( $strLang );
  
      // RETURN
      return response()-&gt;json( $bolUpdated );
   }
  </code></pre>
  
  <p><strong>Route</strong></p>
  
  <pre><code>Route::namespace( 'Settings' )-&gt;prefix( 'settings' )-&gt;group( function () {
  
      ...
  
      // PROFILE
      Route::resource( 'profile', 'ProfileController', ['only' =&gt; ['index','update']] );
      Route::get('test', 'ProfileController@update');
  });
  </code></pre>
  
  <p><strong>settings.profile.js</strong></p>
  
  <pre><code>function initProfileManager() {
  
      // GET ELEMENTS
      var domUpdateLanguage = $('#accountLanguage');
  
      var updateLanguage = function() {
  
          // MAKE AJAX CALL
          $.ajaxq( {
              // url:'/settings/profile',
              url:'./test',
              method:'GET',
              success: function( bolUpdated ) { 
                  if( bolUpdated ) { 
                      alert('OK');
                  }   
              },  
              fail: function() {
                  alert('NO');
              }   
           }); 
           location.reload();
      };  
      domUpdateLanguage.on( 'change', updateLanguage );
  </code></pre>
  
  <p>The way it currently is, I get this error <code>Too few arguments to function App\Http\Controllers\Settings\ProfileController::update(), 0 passed and exactly 1 expected</code>. I understand the error, but not sure how to pass the argument.</p>
  
  <p>If I uncomment the <code>url</code> line from the <code>JS</code>, I never get into the <code>update</code> method and I just end up running <code>index</code> twice.</p>
  
  <p>Any help would be appreciated.</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>Strange. I tried defining a random value and it would still give me that error. I think you might be right and it is a syntax issue. Can't see why it would happen though. </p>
  
  <pre><code>function initProfileManage(strLang) {
  
      // GET ELEMENTS
      var domUpdateLanguage           = $('#accountLanguage');
  
      var updateLanguage = function() {
  
          // MAKE AJAX CALL
          $.ajaxq({
              // url:'/settings/profile',
              url:'./test',
              method:'POST',
              data: { 
                      strLang: newLang,
              }   
              success: function( bolUpdated ) { 
                  if( bolUpdated ) { 
                      alert('OK');
                  }   
              },  
              fail: function() {
                  alert('NO');
              }   
           }); 
           location.reload();
      };  
  
      // UPATE LANGUAGE EVENT
      domUpdateLanguage.on( 'change', updateLanguage );
  }
  </code></pre>