This commit is contained in:
2026-02-19 11:49:56 +01:00
parent c718f15f09
commit 581e726f78
2 changed files with 15 additions and 5 deletions

View File

@@ -80,10 +80,15 @@ class DemoChat {
this.isTyping = true;
try {
const response = await fetch('/scripts/add/send.php', {
// Build absolute URL to ensure correct path on any hosting
const apiUrl = new URL('/scripts/add/send.php', window.location.origin).href;
console.log('Demo Chat: Sending to', apiUrl);
const response = await fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
type: 'chat',
@@ -92,11 +97,14 @@ class DemoChat {
})
});
console.log('Demo Chat: Response status', response.status);
const data = await response.json();
console.log('Demo Chat: Response data', data);
if (data.success && data.data && data.data.ai_response) {
this.addMessageToUI('ki', data.data.ai_response);
} else {
console.error('Demo Chat: Invalid response structure', data);
this.addMessageToUI('ki', 'Entschuldigung, es gab ein Problem. Bitte versuchen Sie es später erneut.');
}
} catch (error) {