You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I am trying to save data in csv files at the latest version of jsPsych, but couldn't manage. I'm wondering if I have a problem with the following code, or with how I ordered the variables?
<script>
var jsPsych = initJsPsych({
display_element: "jspsych-target",
on_finish: function(){ saveData(subjectID, jsPsych.data.get().csv()); }
});
var timelineText = [];
var timelinePicture = [];
var subjectID = prompt('What is your IU user name? (You need to type in your username so we can grant you credits for your participation. Otherwise, we will not know who you are.)');
if (subjectID === '' || subjectID == null) {subjectID=Math.floor(Math.random()*10000).toString()};
jsPsych.data.addProperties({subject_id: subjectID});
[several different trials here]
if (Math.random()<0.5){
jsPsych.run(timelineText);
}
else {
jsPsych.run(timelinePicture);
}
function saveData(name, data){
var xhr = new XMLHttpRequest();
xhr.open('POST', 'write_data.php'); // 'write_data.php' is the path to the php file described above.
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({filename: name, filedata: data}));
}
</script>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am trying to save data in csv files at the latest version of jsPsych, but couldn't manage. I'm wondering if I have a problem with the following code, or with how I ordered the variables?
Beta Was this translation helpful? Give feedback.
All reactions