25 lines
756 B
JavaScript
25 lines
756 B
JavaScript
const NOTIFICATION_HANDLER_URL = '/api/js/handler/NotificationAjaxHandler';
|
|
|
|
async function notificationAjaxRequest(payload) {
|
|
try {
|
|
const response = await fetch(NOTIFICATION_HANDLER_URL, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(payload)
|
|
});
|
|
const data = await parseJsonResponse(response);
|
|
|
|
if (data.error) {
|
|
throw new Error(data.error);
|
|
}
|
|
return data;
|
|
|
|
} catch (error) {
|
|
console.error('Notification-Ajax-Fehler:', error.message);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
function markNotificationAsSeen(nachrichtId) {
|
|
return notificationAjaxRequest({ action: 'mark_seen', nachricht_id: nachrichtId });
|
|
} |