I am trying fetch data on-click on a button.
This is how I return data in my controller:
public function fetch()
    {
        $channels = Channel::where('channel', \Auth::user()->username)
            ->orderBy('created_at','desc')->take(3)->get();
        View::share ('channels', $channels);
    }
And this is the jQuery file:
$( document ).ready(function() {
     $('#dropdownMenu').click(function() {
          $.ajax({
              type: "GET",
              dataType: "html",
              url: "channels/fetch",
              beforeSend: function() {
                    $('.testdropdown').html('loading please wait...');
              },
              success: function(htmldata) {
                  console.log(htmldata);
              }
          });
      });
 });
'loading please wait' part is working but on success, I couldn't make it prompt. What I am missing?

return response()->json(['channels' => $channels ], 200;?View::share ('channels', $channels);to$messages->toJson(); return $messagesand change dataType to 'json'?return $messages->toJson();anddataType: "json"