title: jQuery get returning PHP method undefined Laravel
body: <p>I am using Laravel to build an app and I have a table of users which has a trashcan icon for deleting the user. I am doing this using a <code>get</code> route and a method in my UserController. The method deletes the user and if the user is deleted it <code>echos</code> some json, the user table is rebuilt to show that the user has been deleted. The table does this <code>$table.fadeOut().html('').html(data.build).fadeIn();</code> to be rebuilt. </p>
  
  <p>What actually happens is I press the trashcan icon and the user is deleted, the table's html is deleted, but it is not refresh. The update table method is not being passed for some reason. Now, I know that the <code>updateUsersTable</code> method works because I have a couple of other methods using it. When I <code>console.log(data)</code> to see what is returned, I get this:</p>
  
  <p><code>{"st":1,"msg":"The user was deleted."}{"st":0,"msg":"The user did not get deleted."}</code></p>
  
  <p>The <code>data.build</code> is not sent for some reason.</p>
  
  <p>Here is my code:
  Controller - UserController.php</p>
  
  <pre><code>public function deleteUser($id)
      {
          if(User::deleteUser($id) == true) {
  
              echo json_encode(['st' =&gt; 1, 'build' =&gt; $this-&gt;updateUsersTable(), 'msg' =&gt; 'The user was deleted.']);
  
         } else {
  
              echo json_encode(['st' =&gt; 0, 'msg' =&gt; 'The user did not get deleted.']);      
  
         }
  
      } 
  public function updateUsersTable()
      {
          $output = "";
          $users = User::getUser();
  
          foreach ($users as $user) {
              $output .= '&lt;tr&gt;';
              $output .= '&lt;td&gt;&lt;a href="' . $user-&gt;id . '"&gt;&lt;i class="glyphicon glyphicon-pencil"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/td&gt;';
              $output .= '&lt;td&gt;' . $user-&gt;name . '&lt;/td&gt;';
              $output .= '&lt;td&gt;' . $user-&gt;email . '&lt;/td&gt;';
              $output .= '&lt;td&gt;' . $user-&gt;created_at . '&lt;/td&gt;';
              $output .= '&lt;td&gt;' . $user-&gt;updated_at . '&lt;/td&gt;';
              $output .= '&lt;td&gt;&lt;a href="' . action("UserController@deleteUser", [$user-&gt;id]) . '" class="delete-user-btn pull-right"&gt;&lt;i class="glyphicon glyphicon-trash"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/td&gt;';
              $output .= '&lt;/tr&gt;';
          }
  
          return $output;
      }
  </code></pre>
  
  <p>And my jQuery:</p>
  
  <pre><code>function deleteUserConfirm(){
          if(confirm('Are you sure? This cannot be reversed.') !== true){
              return false;
          } else {
              event.preventDefault();
              var url = $(this).attr('href');
              $.get(url, function(data) {
                  if(data.st === 0){
                      $messageContainer.html('&lt;p class="alert alert-danger"&gt;' + data.msg + '&lt;/p&gt;');
                      setTimeout(function(){
                          $messageContainer.hide();
                      }, 7000);
                  } else {
                      console.log(data.build);
                      $messageContainer.html('&lt;p class="alert alert-success"&gt;' + data.msg + '&lt;/p&gt;');
                      $usersTableBody.fadeOut().html('').html(data.build).fadeIn();
                      setTimeout(function(){
                          $messageContainer.hide();
                      }, 7000);
                  }           
              });
          }
      }
  </code></pre>