Getting the token from javascript

Mehr
2 Monate 1 Woche her #187475 von LarryMartell
Is there a way to access the survey token from my javascript code?

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

LimeSurvey Partners
Mehr
2 Monate 1 Woche her #187476 von jelo
Expression script (aka ExpressionManager) variables are available as strings inside javascript. No objects.

Where do you run your Javascript? Try to assign {TOKEN} as a string to a javascript variable inside your JS code.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Folgende Benutzer bedankten sich: DenisChenu

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
2 Monate 1 Woche her #187495 von LarryMartell
Not sure what you mean by your question. In the browser source tab the JS is running from tmp/assets. Accessing TOKEN gives Uncaught ReferenceError: TOKEN is not defined

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
2 Monate 1 Woche her #187496 von jelo
What version of LimeSurvey is used? Might be a bug or something was changed in a newer version. Is the Survey activated when you test TOKEN?

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
2 Monate 1 Woche her #187498 von LarryMartell
Version 2.73.1+171220. Yes I am taking the survey and I have a break point set in the JS code $(document).ready function and I am checking it there in the debugger.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
2 Monate 1 Woche her - 1 Monat 4 Wochen her #187499 von tpartner
{TOKEN} like all placeholders is rendered at the server level so is only available in JS placed in survey text elements, questions group descriptions or theme TWIG files.

Placeholders are not available in the custom.js file and, unless previously defined, the console.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com
Letzte Änderung: 1 Monat 4 Wochen her von tpartner.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
2 Monate 1 Woche her #187503 von jelo

LarryMartell schrieb: Not sure what you mean by your question.

Tpartner answered that nicely. Sorry, that I didn't realized you're using an external script.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
2 Monate 1 Woche her #187505 von LarryMartell
Ah, the token is in the URL and I can get that in the JS.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
2 Monate 1 Woche her #187506 von tpartner
That will probably only work on the first screen or if using AJAX mode (which I advise against).

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
2 Monate 1 Woche her #187510 von LarryMartell
What about the attributes? Can I access those in my JS?

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
2 Monate 1 Woche her #187513 von tpartner
Token attributes are rendered exactly the same as the token.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner - partnersurveys.com

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
1 Monat 4 Wochen her #187752 von DenisChenu
Easy way : add a javascript function in github.com/LimeSurvey/LimeSurvey/blob/ma...r/custom_header.twig

Something like
<script>
var token = "{TOKEN}";
var surveyId = "{SID}";
var yourVarComeFromSurvey = "{QuestionCode}";
</script>

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
An error happen ? Before make a new topic : remind the Debug mode .
Folgende Benutzer bedankten sich: tpartner

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Jetzt loslegen!

Melden Sie sich jetzt an, und erstellen Sie in wenigen Minuten Ihre erste Umfrage.

Account einrichten

Abonnieren Sie unseren Newsletter

Abonnieren Sie unseren Newsletter für alle Neuigkeiten rund um LimeSurvey
captcha