I have a separate PHP file containing a valid mysql query returning # of Rows representing my criteria (No. of active Notifications), and I have a JQUERY code to display notifications counter, but I only can use it statically with .text('5') for example. I want to be able to link the PHP MYSQL query result to the JQUERY output on browser.
notfcounter.php:
<?php
function getNotCount() {
    require_once $_SERVER['DOCUMENT_ROOT'] . 'info.php';
    $conn   = new mysqli($hn,$user,$pass,$db) or die("Unable to connect");
    $count = $_POST['action'];
    $sqlquery = "SELECT did FROM users WHERE users.uid=".$_SESSION['id'];
    $result = $dbc->query($sqlquery);
    while ($row = $result->fetch_assoc()) {
        $rows = $row['did'];
    }
    $countquery = "SELECT noname, noaction FROM notfs WHERE notfs.did=".$rows." AND notfstatus = 0";
    $result2 = $dbc->query($countquery);
    if (mysqli_num_rows($result2)!=0)
    {  
       $count = mysqli_num_rows($result2);
       echo '<a href="#">'.$count.'</a>';
    }
    else
    {
       $count = 0;
       echo '<a href="#">'.$count.'</a>';
    }
echo $count;
}
?>
JQUERY external file:
$(document).ready(function () {
    // ANIMATEDLY DISPLAY THE NOTF COUNTER.
    $('#notfs_Counter')
        .css({ opacity: 0 })
        //.text('5') this is what I use to display a counter statically
        $.ajax({
        type: 'post',
        url: 'notfcounter.php',
        data: {action: 'getNotCount'},
        success: function(data) {
            alert(data);
        }
    })
        .css({ top: '0px' })
        .animate({ top: '0px', opacity: 1 }, 500);
});
