Java Reference
In-Depth Information
overrideMimeType() method to say that we're expecting JSON data to be returned,
and the send() method to actually send the request. We then place a message in the
question section to say that we're waiting for the questions to load.
The only thing to change now is our event listener that's attached to the start button so that
it calls the getQuestions() function when clicked:
// Event listeners
$start.addEventListener('click', getQuiz , false);
Keeping the quiz data in a separate file and loading it using Ajax is beneficial as it keeps
the question data separate from the actual application logic. It means that it's much easier
to edit all in one place. It also means that we could potentially create lots of different JSON
quiz files that could be linked to, enabling a variety of quizzes to be played.
Search WWH ::

Custom Search