after running javascript code on a qualtrics block it doesn't move to the next block | XM Community
Skip to main content
Hi there,



I've coded a decision-making task in javascript and added in the javascript session in quatrics. The javascript code runs perfectly when I select "view block" option or "preview". However, it stops at the end of the script. A blank page is showed instead of "end preview" (if run using "view block" ) or the button to go to the next block (if run with "preview"). It seems qualtrics is not able to proceed to the next page. Even when I add "end survive" after the block, the blank page is still there. I have tried to simulate click on Qualtrics next button using qualtrics JS API. However, none of the solutions I have tried seems to work (function(){qthis.clickNextButton();}).delay(5); jQuery("#NextButton").click() ; setTimeout(function () {jQuery('#NextButton').click();},2000) and so on..). Running on Onload function or on OnReady function don't change anything. Neither hiding the button and showing that again in the end. Any help is really appreciated. I have attached the script below.
a simpler version of the code is printed below. It has the same problem of mine and it uses jpsych toolbox.



Qualtrics.SurveyEngine.addOnload(function()

{

var qthis = this;

this.hideNextButton();



var hello_trial = {

type: 'html-keyboard-response',

stimulus: 'Hello world!'

}



jsPsych.init({

timeline: [hello_trial],



on_finish: function(data) {

// simulate click on Qualtrics "next" button, making use of the Qualtrics JS API

qthis.clickNextButton();

}

})







});

Leave a Reply