Check out the LimeSurvey source code on GitHub!

Secretly call a page using Javascript

  • asonimie
  • asonimie's Avatar Topic Author
  • Visitor
  • Visitor
6 years 1 day ago #55178 by asonimie
I have a survey and I'm trying to get it to automatically create a token on another survey once they reach a certain question.

Is there any way I can get lime to call a page that will create a token for another survey without the respondent knowing it?

I already have the call page setup, I'm having trouble figuring out the code needed to call to that page.

Our IT guy gave me this code, but it's not working

function loadJSON(url) {
var headID = document.getElementsByTagName("head")[0];
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = url;
headID.appendChild(newScript);
} newUrl = 'http://CALLPAGEADDRESS’; loadJSON(newUrl);

Does this code need to be change to work within lime?

Please Log in to join the conversation.

More
6 years 1 day ago #55179 by holch
Did you change CALLPAGEADDRESS to the url you want to load?

Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

  • asonimie
  • asonimie's Avatar Topic Author
  • Visitor
  • Visitor
6 years 1 day ago #55180 by asonimie
Yes, I put CALLPAGEADDRESS as a place holder in my example. It has the correct link in the actual code.

Please Log in to join the conversation.

More
6 years 1 day ago #55182 by tpartner
As far as I can see, that code works but will only add another JavaScript script to the <head> of the page.

Are you trying to fire a php script?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • asonimie
  • asonimie's Avatar Topic Author
  • Visitor
  • Visitor
6 years 1 day ago #55184 by asonimie
What do you mean when you say it will only add another javascript to the header? Is there a better way to put the code in?

I don't think it should require any PHP. The person who gave me the code is on vacation this week, but when he gave it to me he said it should be able to work all within javascript.

Please Log in to join the conversation.

More
6 years 1 day ago #55185 by tpartner
Can you post the script that is supposed to create a token on the other survey?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

More
6 years 15 hours ago - 6 years 15 hours ago #55205 by Mazi

asonimie wrote: I have a survey and I'm trying to get it to automatically create a token on another survey once they reach a certain question.

Is there any way I can get lime to call a page that will create a token for another survey without the respondent knowing it?

At the end of a survey you can auto-redirect the user to a PHP script which does the token creation. Afterwards you can redirect the user to a predefined end page.
Loading the PHP script is something the user won't really recognize.

Another solution is to use javascript to call the PHP file at survey runtime.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"
Last Edit: 6 years 15 hours ago by Mazi.

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form