ReferenceError: thisExp is not defined error in Pavlovia

Hi!

URL of experiment: https://gitlab.pavlovia.org/MarinaIosifian/childsaleffects

Description of the problem:
I continue getting ```
ReferenceError: thisExp is not defined

Despite the fact that I translated thisExp.addData in JavaScript
psychoJS.experiment.addData

What can be wrong?
1 Like

The JS version for some reason doesn’t (always?) create the experiment handler that in the Python one is called thisExp. You might perhaps create the handler yourself in some of the Begin Experiment blocks, but at least for me it worked to just add the data to the loop handler instead of experiment:

my_loop.addData('key', value);

The name of your loop is whatever name you have given it in Builder (initially I think it’s called trials).

Do you have just the one loop, or several?

Thanks a lot for your response!
There is no loop, because it is a task where participants type the text and it is displayed on the screen.
I just want to save the text they are typing. I have a code component for that. When I launch the experiment on Pavlovia, it allows me to type the text, which is displayed on the screen. But as soon as I type ‘enter’, the error appears that there is a problem with saving the data (thisExp is not defined).

I went to the Experiment handler and realized that my experiment was not called thisExp!
I renamed it and this solved the problem, thank you very much!

Hi Marinalosifian,

This may be a silly question but what is the Experiment handler? Did you change the name of thisExp to the name of the experiment handler file or vice versa?

Thanks for the clarification; I’m new to Pavlovia and am getting the same error message.

If you can find “psychoJS.experiment” in the js code on gitlab. Then it points to your experiment. Change the this.Exp to “psychoJS.experiment” helps