Qualtrics survey engine appears to be running twice (at least in preview) | XM Community
Skip to main content

Qualtrics survey engine appears to be running twice (at least in preview)

  • January 19, 2023
  • 6 replies
  • 446 views

Forum|alt.badge.img+4

This behaviour has been fouling a more complicated survey, so I tried with only a single question. I have added javascript to my questions as follows:
Screenshot 2023-01-18 at 7.11.59 PM.pngEach of these functions appears to be getting called twice in preview mode. Here's what the console looks like:
Screenshot 2023-01-18 at 7.11.11 PM.pngSo OnLoad then On read is run (x2) then onunload (x2).
This means that any variables that I'm assigning are getting cleared null and causing major complications with my more complicated survey. This behaviour just doesn't seem kosher - any ideas on what's happening? I think it might be a JTE thing?
Regards,
Jesse

6 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • January 19, 2023

It does that in preview. Once for the desktop and once for the mobile preview.
Doesn't happen when published.


ArunDubey
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+41
  • QPN Level 8 ●●●●●●●●
  • January 19, 2023

Since there is modile view along with desktop view in preview link. That's why each function is appearing twice.


Forum|alt.badge.img+4
  • Author
  • Level 1 ●
  • January 19, 2023

How to I get it to only preview desktop or mobile? it's causing major issues in debugging my code and I'm not sure it will work.
not accepted answer, but I don't know how to remove it


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • January 19, 2023

Publish. Use the anonymous link to test.


ArunDubey
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+41
  • QPN Level 8 ●●●●●●●●
  • January 19, 2023

Yes, use anonymous link. Do not complete your test run while debugging your code and delete all partial response after each test run.


Forum|alt.badge.img+3
  • Level 1 ●
  • March 3, 2025

You can add Javascript at the top, so that in case of mobile preview, the rest of the Javascript is not executed:

if (jQuery(this.questionContainer).parents('.MobilePreviewFrame').length) {
console.log('Mobile Preview - skipping rest of addOnload')

return true
}