jsPsych.init: jsPsych is not defined error #764
-
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 6 replies
-
Can you post the entire html of your page? It is likely that you did not load jsPsych https://www.jspsych.org/tutorials/hello-world/#step-5-import-the-jspsych-library |
Beta Was this translation helpful? Give feedback.
-
I have. If only it was that easy a solution! <!DOCTYPE html>
<html>
<head>
<title>Typing Twisters</title>
<script src="js\jspsych.js"type="text/js"></script>
<script src="js\plugins\jspsych-html-button-response.js" type="text/js"></script>
<script src="js\plugins\jspsych-instructions.js" type="text/js"></script>
<script src="js\plugins\jspsych-survey-multi-select.js" type="text/js"></script>
<script src="js\examples\jspsych-survey-likert.html" type="text/js"></script>
<link href="css\jspsych.css" rel="stylesheet" type="text/css">
</head>
<body><div id="jspsych-target"></div></body>
<script>
//welcome
var welcome_block = {
type: "html-button-response",
stimulus:"<p>Welcome to this experiment</p>",
choices:['continue']
};
//Instructions
var instruction_block1 = {
data: {
screen_id: "instructions"
},
type: "instructions",
pages: [
"<p>Please answer the following questions to the best of your ability</p>",
],
show_clickable_nav: true
};
//survey
var survey_page1 = {
type: 'survey-text',
questions: [
{prompt: 'How old are you?', columns: 3, required: true, name: 'Age'},
{prompt: 'What country are you from/a citizen of?', placeholder: 'Country', columns: 50, name: 'BirthLocation'}
],
randomize_question_order: true
};
var multi_select_block = {
type: 'survey-multi-select',
questions: [
{
prompt: "Are you right-handed, left-handed or ambidexturous?",
options: ["Right-handed", "Left-handed", "ambidexturous"],
horizontal: true,
required: true,
name: 'hand'
}
],
randomize_question_order: true
};
//Practice
var practice_trial1 = {
stimulus: "five tide type fine",
choices: "ALL_KEYS",
trial_duration: null,
};
var practice_trial2 = {
stimulus: "five tide tap mine",
choices: "ALL_KEYS",
trial_duration: null,
};
//Experiment instructions
var instruction_block2 = {
data: {
screen_id: "instruction2"
},
type: "instructions",
pages: [
"<p>Please type the sequence of words that you see to the best of your ability.</p>"+
"<p>The practice trials are not timed so please press any key to move on to the next page.</p>",
],
show_clickable_nav: true
};
//Experimental trials
var survey_trial1= {
type: 'survey-text',
questions: [
{prompt: "cow bill bat cap"}
],
randomize_question_order: true
};
var survey_trial2= {
type: 'survey-text',
questions: [
{prompt: 'rib mess mad rag'}
]
};
//Typing Survey Questions
var scale = ["Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree"];
var likert_trial = {
type: 'survey-likert',
questions: [
{prompt: "I typically make many mistakes when typing", name: 'TypicalTyping', labels: scale, required: true},
{prompt: "Today I made more typing mistakes than usual.", name: 'TodayTyping', labels: scale, required: true}
],
};
//Debrief
var debrief = {
type: "html-button-response",
stimulus:"<h1>Thank you for participating!</h1>",
choices: ["Click any key to exit the experiment."]
};
//timeline
var timeline= []
timeline.push(welcome_block),
timeline.push(instruction_block1),
timeline.push(survey_page1),
timeline.push(multi_select_block),
timeline.push(practice_trial1),
timeline.push(practice_trial2),
timeline.push(instruction_block2),
timeline.push(survey_trial1),
timeline.push(survey_trial2),
timeline.push(likert_trial);
jsPsych.init ({
timeline: timeline,
show_progress_bar: true,
display_element: 'jspsych-target',
on_finish: function() {
jsPsych.data.displayData('csv')
}
});
</script>
</html>
```html |
Beta Was this translation helpful? Give feedback.
-
Maybe there are more issues, but this is an issue for sure. Make sure you use forward slashes.
Can you give me an idea of your file layout of your experiment?
…On June 18, 2020 1:42:53 AM UTC, rabrya0072 ***@***.***> wrote:
I've tried that before, and just now I tried it again but I still have
the same error message :/ I actually even checked it in Gorilla, which
doesn't use the scripted plug-ins at the top and just relies on you
uploading the plug-ins and the version jspsych you're using and it
doesn't work there either. I just don't know what else to check :/ I
feel like I must be missing a line of code somewhere to activate
jsPsych.init somehow?
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#764 (reply in thread)
|
Beta Was this translation helpful? Give feedback.
-
Oh and additionally, move the script tag into the body tag after your target element.
…On June 18, 2020 1:42:53 AM UTC, rabrya0072 ***@***.***> wrote:
I've tried that before, and just now I tried it again but I still have
the same error message :/ I actually even checked it in Gorilla, which
doesn't use the scripted plug-ins at the top and just relies on you
uploading the plug-ins and the version jspsych you're using and it
doesn't work there either. I just don't know what else to check :/ I
feel like I must be missing a line of code somewhere to activate
jsPsych.init somehow?
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#764 (reply in thread)
|
Beta Was this translation helpful? Give feedback.
-
This is my file layout. I also thought this might be an issue, which is why I checked with Gorilla, which doesn't rely on it. But the error was still there :/ |
Beta Was this translation helpful? Give feedback.
-
Sorry haha, I just realized that the entire script part goes into the body. I did that feeling hopeful...and yet nothing again :/ same error. Just a blank page appears in my browser |
Beta Was this translation helpful? Give feedback.
-
I've even looked into jspsych.js file directly to look for JsPsych.init but it doesn't have anything directly on it other than settings? But again, I am a total beginner so I'm really not sure what my problem is. Everyone else seems to have no problem with jsPsych.init :/ |
Beta Was this translation helpful? Give feedback.
This is my file layout. I also thought this might be an issue, which is why I checked with Gorilla, which doesn't rely on it. But the error was still there :/
When I moved script into the body, it turned off the end body and it won't seem to change back no matter what i do?