Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Variables from OpenSesame to JATOS

I'm trying to send some variables from Qualtrics, and I'm using query strings in this way:

&randomid=${e://Field/randomid}

And then using the following code in a javascript inline code element in my OSWeb experiment:

var randomid = jatos.urlQueryParameters.randomid;

vars.randomid = randomid ? randomid : "unknown";

But somehow, the variable 'randomid' keeps showing up as 'unknown', and if I leave out the last line of the code, it gives me an error saying the variable wasn't found in the variable log.

It's worked previously with exactly the same code, so I have no idea why it wouldn't be working anymore now... Any pointers?

Comments

  • We moved your questions to the OSWeb thread because it seems to be more of a OpenSesame/OSWeb problem. JATOS just makes all query parameters available through  jatos.urlQueryParameters .

  • Hi afkeve,

    Important here is that this code is enclosed by jatos.onload. Is this the case?

    Buy Me A Coffee

  • I'm not exactly sure. I didn't do this before (when it still worked). How do I check this?

  • Then you might have been just lucky. Reliably you can access jatos fields like jatos.urlQueryParameters only after jatos.js in initialized. Usually this is very fast and your code might have worked anyway in most cases but I'd strongly recommend to use the jatos.onLoad function to wait for this initialization.

    jatos.onLoad(function() {
        // Do something with jatos.urlQueryParameters
    });
    

    More in http://www.jatos.org/Mandatory-lines-in-your-components-HTML.html

Sign In or Register to comment.