psychopy.org | Reference | Downloads | Github

Failure to load csv trial file from server (PsychoJS)

Hello all,

I’ve recently been trying to run the “Stroop” demo in my web browser using the “Run PsychoJS task in local debug mode” feature. All the files (index.html, the javascript files) seem to be correctly generated. I then move all the stuff to my Apache2 web server. When accessing “http://localhost/index.html”, the initialisation screen, the participant dialog and then the instruction screen appears. But the program then fails to load the “trialTypes.csv”. This is the output of the console:

FATAL unknown | {“origin”:“TrialHandler.importConditions”,“context”:“when importing condition: trialTypes.csv”,“error”:{“origin”:“ServerManager.getResource”,“context”:“when getting the value of resource: trialTypes.csv”,“error”:“unknown resource”}}

Taking a look at the generated Stroop.js file, the problem seems to start here:

trials = new TrialHandler({
psychoJS: psychoJS,
nReps: 5.0, method: TrialHandler.Method.RANDOM,
extraInfo: expInfo, originPath: undefined,
trialList: ‘trialTypes.csv’,
seed: undefined, name: ‘trials’});

The problem however seems to arise in the “getResource” function of the ServerManager:

getResource(name) {
const response = { origin: ‘ServerManager.getResource’, context: 'when getting the value of resource: ’ + name };
const path_data = this._resources.get(name);
if (typeof path_data === ‘undefined’)
throw Object.assign(response, { error: ‘unknown resource’ });
return path_data.data;
}

Why does this happen? I tried to change the path of the trial file to “./trialTypes.csv” and to an URL “http://localhost/trialTypes.csv” but this doesn’t work either.

Any tips?

Best
Alexander