Rich-text Reply

d.ajax is not a function?

mkstvnsn 11-22-16
Accepted Solution

d.ajax is not a function?

[ Edited ]

Im injecting a script with Optimizely (unfortunately the only way I can do it at my company) and am receiving the error:


Error evaluating experiment javascript:

TypeError: d.ajax is not a function (in function HTMLScriptElement, line 32, col 423)


The company tech support said that the script works isolated from jQuery so that should not be an issue. This is the file in question:


This is how I'm injecting the code:


$("body").prepend("" +          
"<script type='text/javascript' src=''></script>" +
"<script type='text/javascript'>" +
  "wootric_survey_immediately = true;" +
   "window.wootricSettings = {" +
      "account_token: '#######'" +
  "};" +
  "window.wootric('run');" +
Level 2

JasonDahlin 11-23-16

Re: d.ajax is not a function?

If this happens only within this experiment's variation, then it means the code you are injecting is trying to run jQuery that uses the .ajax method either:

1- before a version of jQuery with the .ajax method is loaded on the page

2- the .ajax method is out of scope


I suggest you try the recommended approach for how to add scripts and execute code after the script has loaded.  Using this approach will eliminate manypotential sources of errors.


--Jason Dahlin
Analytics and Testing Guru Smiley Happy

Experimentation Hero
RyanC 11-24-16

Re: d.ajax is not a function?

Are you running trimmed or full JQuery, check under Settings -> Javascript
The best solution is the simplest.
Experimentation Hero