Show loader while async function fetches data #3234
-
Hello, My experiment includes a trial which uses the Thank you! |
Beta Was this translation helpful? Give feedback.
Answered by
Shaobin-Jiang
Feb 16, 2024
Replies: 1 comment 1 reply
-
The example uses a timeout and a line of text instead of a request to the server and the loader gif, but things should work the same way. let jsPsych = initJsPsych();
let timeline = [];
let trial = {
type: jsPsychCallFunction,
func: function (done) {
setTimeout(function () {
jsPsych.getDisplayElement().innerHTML = '';
done();
}, 5000);
},
async: true,
on_start: function () {
jsPsych.getDisplayElement().innerHTML = 'Please wait for 5 seconds...';
},
};
jsPsych.run([trial]); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
talkoren
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The example uses a timeout and a line of text instead of a request to the server and the loader gif, but things should work the same way.