Refresh grid while database updating

Feb 21 2018 2:21 AM
<script type="text/javascript">
var count = 0;
window.onload = function () {
setInterval(ToCallDB, 1000);
// ToCallDB();
};
function ToCallDB() {
var options = {
type: "POST",
url: "Copy of admissionstatus.aspx/retttt",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
$('#<%= Label1.ClientID%>').text(response.d[0]);
$('#<%= Label2.ClientID%>').text(response.d[1]);
},
error: function (response) {
},
complete: function () {
}
};
$.ajax(options);
}
</script>
 
This is my ajax call for refreshing label every 1 sec. Here i do want to update the label when database has been updated.
Is it possible without  setInterval()?

Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.

Answers (1)