title: JS for playing beep sound for notification not working as expected
body: <p>I have a script which does an ajax call to receive notifications from some page.The data received in the callback function is an <strong><em>integer(0,1,2,3...)</em></strong> only which is the number of rows selected in the query . Please find the query I am using in the description below.</p>
  
  <p>I am using the following JS  : </p>
  
  <pre><code>            function myFunction() {
                  $.get("AjaxServicesNoty.aspx", function (data) {
                      var recievedCount = data;
                      var existingCount = $("lblEventCount").text();
  
                      if (existingCount == "") {
                          $(".lblEventCount").html(recievedCount);
                          $(".lblAcceptedCount").html(recievedCount);
                          var sound = new Audio("Sound/notificatonSound.wav"); // buffers automatically when created
                          sound.play();
                      }
  
                      else if (parseInt(recievedCount) &gt; parseInt(existingCount)) {
                          $(".lblEventCount").html(recievedCount);
                          $(".lblAcceptedCount").html(recievedCount);
                          var sound = new Audio("Sound/notificatonSound.wav"); 
                          sound.play();
                      }
  
                      else {
                          $(".lblEventCount").html(existingCount);
                          $(".lblAcceptedCount").html(existingCount);
  //                        var sound = new Audio("Sound/notificatonSound.wav"); 
  //                        sound.play();
                      }
                  });
              }
              setInterval(myFunction, 3000);
  </code></pre>
  
  <p>The sound plays fine <strong><em>now</em></strong>. Now as the <code>setInterval()</code> function is called , every three seconds the beep keeps playing even though according to my <code>if-else</code> conditions . It shouldn't be playing so . It should be only played if there are new updates .</p>
  
  <p>I have used the following query  : </p>
  
  <pre><code>public int getAcceptedCount(int CustomerID)
          {
              string query = @"SELECT Status
                              FROM    tblEventService
                              WHERE   EventID IN  (SELECT EventID FROM tblEvent WHERE (CustomerID = @cid)) AND (Status = 'Accepted' OR Status = 'Rejected')";
  
              List&lt;SqlParameter&gt; lstP = new List&lt;SqlParameter&gt;();
  
              lstP.Add(new SqlParameter("@cid", CustomerID));
  
              DataTable dt = DBUtility.SelectData(query, lstP);
  
              if (dt.Rows.Count &gt; 0)
              {
                  return dt.Rows.Count;
              }
              else 
              {
                  return 0;
              }
          }
  </code></pre>
  
  <p>The query selects all the rows whose <code>Status</code> is <code>Accepted or Rejected</code>. So if there are any new <code>Accepted or Rejected</code> events, the count will increase. And thus the JS should play the notification sound!</p>
  
  <p>What am i doing wrong here ?</p>