Search code examples
jquerymessagebox

jquery: Flash messages


With jQuery, how can I display a flash message at the top of the page in an easy way? Is there something built-in, or a plugin, or is it easy enough to do it yourself?

What I mean is like after a successful ajax post I would like to just say "hey, it went good" in a non-obtrusive way.


Solution

  • I would check out the jQuery growl style plugins available if you're looking for something quick to implement :)

    The .ajaxSuccess() would be a good place to run your code, or for errors .ajaxError(), these are some of the global ajax event handlers available, for example:

    $(document).ajaxSuccess(function() {
      //fire success message using the plugin of choice, for example using gritter:
      $.gritter.add({ 
        title: 'Save Complete!',
        text: 'Your request completed successfully.'
      });
    });