** ANGULAR 1.X ** Hello everyone! I need help with making this $http.get function asynchronous, as you can see from the code, my current temp solution is to setInterval the displayData scope. Which obviously is not an efficient solution, because it takes up too much CPU, too much of the users data and can cause some flickering on the UI. I want the array to be updated when the database is updated. Please do not recommend I switch to other frameworks. thank you
$scope.displayData = function() {
$http.get("read.php").success(function(data) {
$scope.links = data;
});
}
setInterval(function(){$scope.displayData();}, 500);
This is my PHP ("read.php")
<?php
include("../php/connect.php");
session_start();
$output = array();
$team_id = $_SESSION['team_id'];
$sql = "SELECT record_id, user_id, link, note, timestamp FROM
link_bank WHERE team_id = '$team_id' AND status = 'valid'";
$result = mysqli_query($connect, $sql);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_array($result)) {
$output[] = $row;
}
echo json_encode($output);
}
?>