Welcome, Guest
Username: Password: Remember me

TOPIC: Secretly call a page using Javascript

Secretly call a page using Javascript 3 years 9 months ago #55178

  • asonimie
  • asonimie's Avatar
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?
The administrator has disabled public write access.

Re: Secretly call a page using Javascript 3 years 9 months ago #55179

  • holch
  • holch's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2851
  • Thank you received: 358
  • Karma: 124
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 | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

Re: Secretly call a page using Javascript 3 years 9 months ago #55180

  • asonimie
  • asonimie's Avatar
Yes, I put CALLPAGEADDRESS as a place holder in my example. It has the correct link in the actual code.
The administrator has disabled public write access.

Re: Secretly call a page using Javascript 3 years 9 months ago #55182

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4271
  • Thank you received: 805
  • Karma: 369
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Secretly call a page using Javascript 3 years 9 months ago #55184

  • asonimie
  • asonimie's Avatar
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.
The administrator has disabled public write access.

Re: Secretly call a page using Javascript 3 years 9 months ago #55185

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4271
  • Thank you received: 805
  • Karma: 369
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Secretly call a page using Javascript 3 years 9 months ago #55205

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5331
  • Thank you received: 296
  • Karma: 249
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)limesurvey.org'"
Last Edit: 3 years 9 months ago by Mazi.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.116 seconds
Donation Image