Replies: 2 comments
-
You can wrap the construction of your experiment in a function and then call that function from the async callback: function build_timeline(){
var trial = { ... } // etc..
jsPsych.init({ ... }) // etc..
}
$.ajax({
success: function(data) {
test_stimuli = data;
build_timeline();
}
}); |
Beta Was this translation helpful? Give feedback.
0 replies
-
Another option, which doesn't quite answer your question but would solve the same problem, is to take your JSON file and convert it to JS with a single modification Here's the JSON [{"property": "value"}] To make JS: var my_json = [{"property": "value"}] If the file is JS instead of JSON, you can just load it via a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I'm trying to figure out the best way to load trial information from an external JSON file.
Currently I'm using synchronous AJAX calls to load in an array JSON object:
This works, but is synchronous and apparently deprecated in the current jQuery version This is fine for my experiment, because the JSON file is very small. How would I use the async callback function to delay the construction of the trials until the file is loaded?
Beta Was this translation helpful? Give feedback.
All reactions