Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Toastr notification not working

I tried the following code but nothing's popping up when I launch the page in my browser

$(function () { //ready
    toastr.info('For more information, see our FAQ guide located below.');
});
like image 904
Oisín Foley Avatar asked Jan 14 '15 23:01

Oisín Foley


People also ask

What is Toastr notification?

toastr is a simple JavaScript toast notification library that is small, easy to use, and extendable. It allows you to create simple toasts with HTML5 and JavaScript like this: Simply include the files in your HTML page and write a simple line of code like this: toastr.

How can I redirect after Toastr notification?

See the 'callbacks' section of the documentation: github.com/CodeSeven/toastr. Secondly, making an AJAX request then showing a notification is redundant if you're going to redirect anyway. Instead of making a single request you've made two and held up your user while they waited for the notification to go away.


1 Answers

If you've included jQuery, toastr.js, and toastr.css in your page, then this should work. I'd make sure to check to see if your path to these scripts are all correct, and I'd check the console for any errors.

<script src="/example-path-to/jquery-2.1.4.js"></script>
<script src="/example-path-to/toastr.js"></script>
<link href="/example-path-to/toastr.css" rel="stylesheet" />

<script>
      $(function () { //ready
          toastr.info('If all three of these are referenced correctly, then this should toast should pop-up.');
      });
</script>
like image 52
alex Avatar answered Nov 03 '22 00:11

alex