Having trouble determining the condition to test for when a new record is added to the database table. Can anyone lend a hand?
Here's a snippet of the data retrieved from the database:
['Paul Abioro', '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9bebfaeef7fee3edb5b5b5dbfcf6faf2f7b5f8f4f6">[email protected]</a>', 'chester', 'Teejay', 'Hi Teejay', '3', '2023-04-06 17:42:54']
['Paul Abioro', '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="314150445d5449471f1f1f71565c50585d1f525e5c">[email protected]</a>', 'chester', 'Teejay', 'How are you doing?', '3', '2023-04-06 17:42:58']
This is the AJAX code used to fetch records from the database, and I'm struggling with what to compare "datum.length" against in my conditional statement.
load_messages = function(){
$.ajax({
url:"json/chat-content.php",
method:"POST",
data:{recipient_id:query_id},
dataType: "JSON",
success:function(resp) {
let datum = resp.response;
//condition for when the new record is added to the database
if(datum.length == ){
let audio = new Audio("assets/audio/mixkit-confirmation-tone-2867.mp3");
audio.play();
}
setTimeout(load_messages, 60000);
},
error: function (data) {
console.log(data);
}
});
}