• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
Bagisto Forum

Bagisto

  • Register
  • Login
  • Search
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups

Flash cannot trigger after AJAX response

Knowledge Base
2
4
817
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V
    valpuia last edited by valpuia 6 Nov 2019, 10:54 6 Nov 2019, 10:54

    I create new packages, and add new pages also. I have to update data using Ajax and shows the flash-message to the user that the data is updated. But If I use window.flashMessages = [{ 'type': 'alert-success', 'message': 'Updated'}]; nothing shows in my page. If I use alert like success: function(response){ alert('Updated'); } then alert is showing. Any Idea to use flash message.

    1 Reply Last reply Reply Quote 0
    • R
      rahul last edited by 6 Nov 2019, 12:13

      Hi @valpuia

      Can you attach your views master file, so that we can check.

      Thanks

      1 Reply Last reply Reply Quote 0
      • V
        valpuia last edited by valpuia 7 Nov 2019, 03:59 7 Nov 2019, 03:58

        Hi @rahul
        here's the blade file.. my route and controllers are working fine.

        @extends('admin::layouts.master')
        
        @section('page_title')
            {{ __('menus::app.menus.page_title') }}
        @stop
        
        @section('content-wrapper')
            <div class="page-content">
               <div class="dd" id="menuNestable">
                 <ol class="dd-list">
                   @foreach ($menus as $menu)
                     <li class="dd-item dd3-item" data-id="{{ $menu->id }}" >
                      <div class="dd-handle dd3-handle"></div>
                     </li>
                    @endforeach
                  </ol>
               </div>
              </div>
        @endsection
        
        @push('scripts')
            <script src="/js/jquery.nestable.js"></script>
            <script>
              $('#menuNestable').on('change', function() {
                 var dataString = { 
                    data : $("#nestable-output").val(),
                };
              
               $.ajaxSetup({
                headers: {
                  'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
              });
              
              $.ajax({
                type: "POST",
                url: "{{ route('menus.update') }}",
                data: dataString,
                cache : false,
                success: function(response){
                  // alert('Updated');
                  window.flashMessages = [{
                   'type': 'alert-success',
                   'message': 'Updated'
                  }];
                }, error: function(xhr, status, error) {
                    alert(error);
                },
              });
            });
          </script>
        @endpush
        
        1 Reply Last reply Reply Quote 0
        • 7 days later
        • R
          rahul last edited by 14 Nov 2019, 04:51

          Hi @valpuia

          Try with this one -

           window.flashMessages = [{
                    'type': 'alert-success',
                   'message': 'Updated'
           }];
          
          this.$root.addFlashMessages()
          

          Thanks

          1 Reply Last reply Reply Quote 0
          1 out of 4
          • First post
            1/4
            Last post