jquery: Flash messages

前端 未结 8 1686
再見小時候
再見小時候 2021-02-12 21:05

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?

W

8条回答
  •  误落风尘
    2021-02-12 21:36

    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.'
      });
    });
    

提交回复
热议问题