PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, March 4, 2022

[FIXED] Session flash message timeout in Laravel

 March 04, 2022     laravel, laravel-5, php     No comments   

Issue

I have created flash message in Laravel page using controller. It's showing well but need to add timeout in flash message

if($location_vaidation>0){
     $material_details->location_id=$requested_location;     
     }
     else{
        Session::flash('success', 'please fill the form with valid data');
        return Redirect::to('request');
        exit;           
     }  

In view page

@if( Session::has("success") )
  <div class="alert alert-success alert-block" role="alert">
  <button class="close" data-dismiss="alert"></button>
  {{ Session::get("success") }}
 </div>
 @endif
 @if( Session::has("error") )
  <div class="alert alert-danger alert-block" role="alert">
  <button class="close" data-dismiss="alert"></button>
  {{ Session::get("error") }}
 </div>
 @endif
 <div class="flash-message"></div>

Solution

Try this using Jquery function

$("document").ready(function(){
    setTimeout(function(){
       $("div.alert").remove();
    }, 5000 ); // 5 secs

});


Answered By - Kiran Patel
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing