Search code examples
javascriptphpjquerypnotify

How to call PNofity in PHP if statement?


I am trying to show a PNotify pop up if a condition is met, but nothing seems to be happening, this is my if statement:

<?php if($days < 60) { echo "
<script type='text/javascript'>
    $(document).ready(function(e) {
        notifyUser('success');
    });
</script>";?>
<?php if($days < 0) { ?>
    <tr style="color: #641E16;">
        <td> <?php echo $customer['CardName'];?> </td>                      
        <?php if($days < -2) {?>
            <td style="min-width: 90px;">Exprired!</td>
        <?php }elseif($days == -1){?>
            <td style="min-width: 90px;">Today!</td>
        <?php }else{ ?>
            <td style="min-width: 90px;"><?php echo $days;?> days</td>
        <?php } ?>

        </tr>   
<?php } ?>

and i have this javascript:

<script type="text/javascript">
function notifyUser(message) {
    if(message == "success") {
        new PNotify({
            title: 'Popup Title',
            text: 'Your form as been submitted'
        });
    }
}
</script>

Am I missing something?

Any help would be appreciated.


Solution

  • My jQuery was being called after my funtion.