Rich-text Reply

Type Error at Experiment JavaScript

Mr-BS 05-26-16
Accepted Solution

Type Error at Experiment JavaScript

Hey,

I have these 3 lines of code in a experiment javascript window:

$(document).ajaxComplete(function(event,request, settings) {
  console.log('works');
});

but I received in the editor an type error that ajaxComplete is not a function.

I´m not including jQuery in the optimizely snippet, but include my selfe hosted version before the optimizely snippet. By the way I dont think that it is an problem with the jQuery library cause other experiments work fine.

Any advice how I can make this work?

 

Level 2

tedroddy 05-27-16
 

Re: Type Error at Experiment JavaScript

Hi sRBjoern,

Our Javascript evaluator sometimes emits errors when there is no error. If the ajaxComplete function is working properly on your page when the experiment runs, then you should have nothing to worry about and can safely ignore the error in the editor.

Another option you have is to try using window.$(document) instead of just $(document) as sometimes the Editor will pick up your page's jQuery and see that that method really does exist.
Best,
Ted
Optimizely