[Vuejs]-Making an Ajax call for Vue multiselect options in Laravel

0👍

One thing that comes to my attention is that you are using success: results => this.options = results in your success function for the ajax request. One common mistake is that this in this particular context doesn’t refer to the vue instance but the ajax request.

So what could get you a step further is to create an explicit reference to the vue instance upfront:

pullEmployees() { 
   var vue = this; 
   $.ajax({
      url:"{{ route('campaigns.search') }}",
      method:"POST",
      data:{query:query, _token: '{{ csrf_token() }}'},
      success: results => vue.options = results
    });
  }

This should at least set the your vue instance options to the results provided by the ajax request.

Maybe you can proceed further with this information.

Leave a comment