Topic: How to trigger toaster after getting ajax response ?

imhim45 free asked 6 years ago


Hey there, I wanted to trigger a toaster when user authentication gets success. For example - If a user Clicks on Login button then AJAX will check credentials using PHP in back end and will give a response. I want to trigger the toaster at that time.
Start your code here
$.ajax({
type:"POST",
url:'functions/action.login.php',
data:'email='+email+'&password='+password,
dataType:"text",
beforeSend:function(){
$("#submit").prop('value', 'Loading..');
},
success:function(data){
if(data!=0){
//I want toaster to trigger here when login is successful.
$(location).attr('href',data);
}

Anna Morawska staff commented 6 years ago

Hello, so, after success ajax call you want to redirect the user to another URL and then trigger the toaster? It's quite tricky, redirecting will kill all scripts currently running in the browser. Maybe try to pass a parameter in the URL, and then depending on the passed parameter trigger a toaster on a new page. Is this resolve your problem? Best, Ania

imhim45 free commented 6 years ago

Got it. I'll pass a url param and will trigger toaster on Dashboard. But How do I do that ? I don't know how to trigger toaster other than onclick()

Anna Morawska staff answered 6 years ago


Hey, you can trigger a toaster via jQuery : toastr["info"]("I was launched via jQuery!") You can check how it works on our docs page, just open the console and paste it in. You can read more about that in our documentation. Best, Ania

caqexelo free commented 1 year ago

trrgertetretetetreter



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags