I recently developed a website for purchasing online. My problem is how I can create notification to alert at admin page when new order is inserted into MySQL. This notification will appear as an icon number at admin page on website, so that when admin open website they will know new order had made by customer.
I know we have to use javascript ajax but I have not idea how to begin.
I have some example code:
refreshInterval = 500
refreshTimeout = setTimeout(getNotificationCounts, refreshInterval);
function getNotifications() {
$.ajax({
url: 'path_to_your_php',
type: 'POST',
data: //put for example user_id but it cvan be handled by sesion as
dataType: 'json',
success: function (data) {
alert('You have' + data.total + ' new messages')
refreshTimeout = setTimeout(getNotificationCounts, refreshInterval);
}
});
}