jQuery 1.11.3 & DataTables

Last night I finished up some final touches on a plugin that I have been working on for my WordPress website.  Working on my local development server, everything looked and worked great!  So, I fired up FileZilla and uploaded the plugin to my production server.  I ran it through a test and found it didn’t work the way I expected it to.  Hmmmm.

The portion of the plugin in question was using Ajax to get a text file and display it’s contents in a jQuery DataTables.  On my production server, using Chrome’s debug console, I could see my code was producing the following error;

Uncaught TypeError: Cannot use ‘in’ operator to search for ‘length’ in

 

A few minutes of Google searching led me to this post on StackOverflow, which ultimately helped me solve the issue.  The issue presents itself when using jQuery version 1.11.3 and the DataTables extension version 1.10.6.  With a little digging, it was easy to find out why this issue presented itself on one site and not another.  My development site is on WordPress 4.2 and my production site is on WordPress 4.3.  The difference is the jQuery version loaded by the WordPress core (versions 1.11.2 and 1.11.3 respectively).

Now, the decision is to downgrade jQuery to 1.11.2 in the WordPress core (which is NEVER a good idea), or look at changing versions of DataTables.  According to the SO post linked above, DataTables versions 1.10.7 and 1.10.8-dev did not fix the issue for one commenter using jQuery 1.11.3, while the 1.10.7 update resolved the issue for another commenter who was using jQuery 2.1.4.  Luckily,  DataTables version 1.10.9 has been out since September 2015, which resolved the issue for me, using jQuery version 1.11.3 (WordPress 4.3 core).