jQuery notification Plug-in

9lessons.info - Ravi Tamada

The Basic Setup

Usage:



Using notification plugin with Ajax Calls

Below is an example of using this plug in with Ajax calls
                $.ajax({
                    type: "POST",
                    data: post_parmas,
                    url: "sample.php",
                    error: function (msg) {
                        // Error occurred in sending request
                        showNotification({
                            message: "Oops! an error occurred.",
                            type: "error" // type of notification is error
                            autoClose: true, // auto close to true
                            duration: 5 // display duration
                        });
                    },
                    success: function (msg) {
                        showNotification({
                            message: "Show Ajax result message here!",
                            type: "error" // type of notification is error/success/warning/information,
                            autoClose: true, // auto close to true
                            duration: 5 // message display duration
                        });
                    }
                });
            


Using with PHP

Below is an example of using plugin with PHP code. The following code will display a message by reading PHP Get parameters.
Always place this code at the end of your page.
                <?php
                if (isset($_GET["type"])) {
                    $message = $_GET["message"];
                    $type = $_GET["type"];
                    ?>
                     <script type="text/javascript">
                        showNotification({
                            message: "<?php echo $message; ?>",
                            type: "<?php echo $type; ?>",
                            autoClose: true,
                            duration: 5                                        
                        });
                    </script>
                    <?php
                }
                ?>
            

Demo: