7357963110
Goto Top

Error 500 Ajax

Hi,

ich verwende in meinem Code ein Script, welches eine HTTP Anfrage an den serverseitigen Punkt sendet. Vom Grunde her findet der Server alles, was er braucht. Er gibt mir nur einen Error 500 zurück. Chrome DevTools gibt mir den Fehler bei
"xhr.send();"
Was könnte in diesem Fall das Problem sein?


hier der Code:

  <script>

        function getQuizData() {

            var xhr = new XMLHttpRequest();
            xhr.open('GET', 'get_questions.php', true);  
            xhr.onreadystatechange = function () {

                if (xhr.readyState === 4 && xhr.status === 200) {
                    var quizData = JSON.parse(xhr.responseText);
                    displayQuiz(quizData);
                }
            };
           xhr.send();
        }

        function displayQuiz(quizData) {

            var quizContainer = document.getElementById('quiz-container');  


            var randomQuestions = shuffleArray(quizData.questions).slice(0, 30);


            randomQuestions.forEach(function (question) {

                var questionElement = document.createElement('div');  

                questionElement.innerHTML = '<h3>' + question.question + '</h3>';  


                question.choices.forEach(function (choice) {

                    var choiceElement = document.createElement('input');  

                    choiceElement.type = 'radio';  

                    choiceElement.name = question.id;

                    choiceElement.value = choice;

                    questionElement.appendChild(choiceElement);

                    var labelElement = document.createElement('label');  

                    labelElement.innerHTML = choice;

                    questionElement.appendChild(labelElement);

                    questionElement.appendChild(document.createElement('br'));  

                });

                questionElement.addEventListener('change', function (event) {  
                    var selectedAnswer = event.target.value;
                   if (selectedAnswer === question.correctAnswer) {

                        alert('Richtige Antwort!');  

                    } else {

                        alert('Falsche Antwort!');  
                    }
                });
                quizContainer.appendChild(questionElement);

                quizContainer.appendChild(document.createElement('hr'));  

            });
        }

        function shuffleArray(array) {
           var currentIndex = array.length,
                temporaryValue,
                randomIndex;

            while (0 !== currentIndex) {
                randomIndex = Math.floor(Math.random() * currentIndex);
                currentIndex -= 1;

                temporaryValue = array[currentIndex];
                array[currentIndex] = array[randomIndex];
                array[randomIndex] = temporaryValue;
            }
            return array;
        }  
        getQuizData();

    </script>

Content-ID: 7360051655

Url: https://administrator.de/contentid/7360051655

Ausgedruckt am: 25.10.2024 um 07:10 Uhr

SlainteMhath
Lösung SlainteMhath 30.05.2023 um 13:11:08 Uhr
Goto Top
Moin,

Was könnte in diesem Fall das Problem sein?
Das "Geheimnis" steht im error.log des Webservers face-smile

lg,
Slainte
7357963110
7357963110 30.05.2023 um 16:40:08 Uhr
Goto Top
Dort wird die Class "COM" nicht gefunden. Muss ich irgendwelche Erweiterungen oder so installieren?
HansFenner
HansFenner 30.05.2023 um 21:12:04 Uhr
Goto Top
Woher sollen wir das wissen, wenn du keinerlei Angaben machst, was da läuft ? face-smile
SlainteMhath
SlainteMhath 31.05.2023 um 08:00:27 Uhr
Goto Top
Dort wird die Class "COM" nicht gefunden.
Error Log, nicht Eventlog face-smile