Title: Plugin Causing Javascript Error in WordPress Admin
Last modified: August 30, 2016

---

# Plugin Causing Javascript Error in WordPress Admin

 *  Resolved [Salpetriere](https://wordpress.org/support/users/salpetriere/)
 * (@salpetriere)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/)
 * Jock on air now is causing the following Javascript error on all admin pages 
   of WordPress.
 *     ```
       SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
   
       ...tion(b){if(a.JSON&&a.JSON.parse)return a.JSON.parse(b+"");var c,d=null,e=m.trim(...
       ```
   
 * I’ve deactivated all other plugins and switched themes and can confirm that this
   plugin is causing the js error.
 * I’m using the latest version of WordPress.
 * The js error is causing a few other admin functions not to work correctly.
 * Is there a fix for this?
 * [https://wordpress.org/plugins/joan/](https://wordpress.org/plugins/joan/)

Viewing 15 replies - 1 through 15 (of 27 total)

1 [2](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/page/2/?output_format=md)

 *  Plugin Author [ganddser](https://wordpress.org/support/users/ganddser/)
 * (@ganddser)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/#post-6895302)
 * Since you’re the first to report this, I’ll have to run some simulations to try
   an replicate this issue to make sure. No promises on a quick solution as it’s
   New Years Eve and my office is closed.
    In the meantime this seems like an issue
   caused by the jQuery version that’s running. One question is your hosting environment?
 *  Thread Starter [Salpetriere](https://wordpress.org/support/users/salpetriere/)
 * (@salpetriere)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/#post-6895332)
 * Thanks for the response ganddser. No probs with the delay.
 * The hosting environment is a shared Apache server running PHP 5.6.
 * I’ve read that [having mod_sec enabled on the server](https://wordpress.org/support/topic/error-jsonparse-unexpected-character-at-line-1-column-1-of-the?replies=6)
   can cause issues with AJAX. Could that be an issue here?
 *  Plugin Author [ganddser](https://wordpress.org/support/users/ganddser/)
 * (@ganddser)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/#post-6895418)
 * We were unable to reproduce the error you reported. Can you provide anymore details
   about your WP install? Also if possible ask your host to disable mod_sec as it
   can indeed “cause the server to respond with an HTML page instead of the Ajax
   response.”
 *  Thread Starter [Salpetriere](https://wordpress.org/support/users/salpetriere/)
 * (@salpetriere)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/#post-6895440)
 * I’ve been in touch with the hosting provider & they have informed me that it 
   is indeed a development error with the plugin.
 * I therefore tested the plugin across multiple hosting environments and can confirm
   that the error is consistently occurring across each of them.
 * Do you know how to identify javascript errors? You’ve got to check the console
   in your browser dev tools (try using the console tab in [Firebug](http://getfirebug.com/)).
 * Here’s a screengrab of the error as presented in firebug (site url obscured for
   privacy) – [http://postimg.org/image/tqzc0zegt/](http://postimg.org/image/tqzc0zegt/)
 * The error is only present when you are on pages of the WP dashboard. If you look
   for it on the front end of the site you wont see anything, even when logged in.
 * The error is causing other functions not to work in my admin/dashboard. This 
   has been confirmed by deactivating the plugin, at which point the functions begin
   working again.
 *  Plugin Author [ganddser](https://wordpress.org/support/users/ganddser/)
 * (@ganddser)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/#post-6895443)
 * OK, we are still not able to reproduce this error. We have this plugin installed
   on several of our customers websites and on our own sites as well none of them
   show this error, all different themes mostly the same Apache hosting environment.
 * Let me ask you this:
 * Did you modify the plugin in anyway?
    Was this the first time you installed this
   plugin, and or did you have it’s predecessor (Showtime) installed at anytime 
   before installing Joan?
 * Have you tried uninstalling the plugin and remove all Joan entries from your 
   WP database and reinstall it from the plugin directory.
    (Compatibility up to
   WordPress 4.4.1)
 *  Thread Starter [Salpetriere](https://wordpress.org/support/users/salpetriere/)
 * (@salpetriere)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/#post-6895448)
 * Thanks for your response.
 * Just as a side note, I can rule out mod_sec being an issue here. I have tested
   disabling it across a number of servers and it makes no difference, the error
   still occurs.
 * My answers to your queries are below.
 * _Did you modify the plugin in anyway?_ On the initial site that I experienced
   the issue I had, yes. When I tested it with other hosting providers though I 
   installed the straight plugin straight from the repository and still experienced
   the issue.
 * _Was this the first time you installed this plugin, and or did you have it’s 
   predecessor (Showtime) installed at anytime before installing Joan?_ On the initial
   site that I experienced the issue I had Showtime installed previously. When testing
   with other hosting providers though the Joan plugin was installed without Showtime,
   same results.
 * _Have you tried uninstalling the plugin and remove all Joan entries from your
   WP database and reinstall it from the plugin directory._ On the testing sites
   the plugin was installed directly from the repository on a new WP install, with
   the same error occurring. How would that help in this instance?
 *  Thread Starter [Salpetriere](https://wordpress.org/support/users/salpetriere/)
 * (@salpetriere)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/#post-6895449)
 * After posting my previous message I [enabled WP_DEBUG and WP_DEBUG_LOG](https://codex.wordpress.org/Debugging_in_WordPress).
 * In doing so I’ve been able to identify that the plugin is throwing the following
   php errors (via wp-content/debug.log).
 * `The called constructor method for WP_Widget is deprecated since version 4.3.0!
   Use __construct() instead.`
 * `has_cap was called with an argument that is deprecated since version 2.0! Usage
   of user levels by plugins and themes is deprecated. Use roles and capabilities
   instead.`
 * Further info on these errors can be found [here](https://wordpress.org/support/topic/constructor-method-for-wp_widget-is-deprecated-since-430?replies=31)&
   [here](https://wordpress.org/support/topic/has_cap-was-called-with-an-argument-that-is-deprecated?replies=13).
 * It appears the plugin is using outdated WordPress functions and needs to be updated
   for the latest version. Are you doing your testing for the javascript error on
   the latest version of WordPress?
 * Additionally I’m getting the following error when deactivating then reactivating
   the plugin.
 * `The plugin generated 308 characters of unexpected output during activation. 
   If you notice “headers already sent” messages, problems with syndication feeds
   or other issues, try deactivating or removing this plugin.`
 * Using [this](https://wordpress.org/plugins/debug-plugin-activation-errors/) tool(
   with WP_DEBUG enabled), I’ve been able to identify the source of the ‘unexpected
   output’ error in the plugin code, as below.
 *     ```
       Notice:  Undefined variable: wpdb in /wp-content/plugins/joan/joan.php on line 20
   
       Notice:  Trying to get property of non-object in /wp-content/plugins/joan/joan.php on line 20
       ```
   
 * Information on declaring wpdb as a global variable can be found [here](https://codex.wordpress.org/Class_Reference/wpdb).
 * If required, more information on the ‘unexpected output’ error can be found [here](http://stackoverflow.com/questions/4074477/the-plugin-generated-x-characters-of-unexpected-output).
 * I would encourage you to [enable WP_DEBUG and WP_DEBUG_LOG](https://codex.wordpress.org/Debugging_in_WordPress)
   in your wp-config file and have a look over the deprecated functions currently
   being used in the code. There’s quite a few errors with the plugin that need 
   to be resolved.
 *  Plugin Author [ganddser](https://wordpress.org/support/users/ganddser/)
 * (@ganddser)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/#post-6895450)
 * Ok Fixed these: The called constructor method… The plugin generated 308, a result
   of this (Undefined variable: wpdb).
 * Only 1 issue when I fix this (has_cap was called with an argument that is deprecated
   since version 2.0! Usage of user levels by plugins and themes is deprecated. 
   Use roles and capabilities instead.)
 * All WP errors a fixed but the Current Schedule disappears, when using the # in
   place of Use roles and capabilities instead.
 * The current schedule shows up again.
    I’m sure it’s something simple I’m missing,
   can’t seem to see it now.
 *  Thread Starter [Salpetriere](https://wordpress.org/support/users/salpetriere/)
 * (@salpetriere)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/#post-6895454)
 * [Here’s](https://wordpress.org/support/topic/notice-has_cap-called-with-an-argument-that-is-deprecated?replies=13)
   a thread where other users have exemplified how to updated the has_cap function,
   and another [here](https://wordpress.org/support/topic/has_cap-was-called-with-an-argument-that-is-deprecated?replies=13).
 * I see you’ve resolved the ‘unexpected output’ error with the latest update. Thanks
   for that.
 * The javascript error in the admin still persists though. It will be interesting
   to see whether the resolution of the deprecated function has_cap resolves that
   issue.
 * Also, with the updated version of the plugin you’ve accidentally wrapped each
   list of shows in the front end program guide with <li class=”joan-schedule”> 
   tags rather than <ul class=”joan-schedule”> tags. Could you fix that up?
 * One last thing, any chance we can include my provided code for displaying the
   programs on air today in the plugin? I’m having to manually include this with
   each update.
 *  Plugin Author [ganddser](https://wordpress.org/support/users/ganddser/)
 * (@ganddser)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/#post-6895458)
 * All deprecated functions no errors, added your “schedule-today function.” If 
   you’re still experiencing the admin error consider trying our hosting service.
 *  Thread Starter [Salpetriere](https://wordpress.org/support/users/salpetriere/)
 * (@salpetriere)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/#post-6895459)
 * Thanks for the updates ganddser.
 * Unfortunately the fix mentioned above for the incorrect list markup wasn’t applied.
 * The code that needs to be amended is in joan.php on lines 165 & 179.
 * Line 165 needs to be changed to the following,
 * `$output .= '<ul class="joan-schedule">';`
 * Line 179 needs to be changed to the following,
 * `$output .= '</ul>';`
 * Could you apply these updates? Thanks.
 *  Plugin Author [ganddser](https://wordpress.org/support/users/ganddser/)
 * (@ganddser)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/#post-6895462)
 * Done. Thanks for the feedback.
 *  Thread Starter [Salpetriere](https://wordpress.org/support/users/salpetriere/)
 * (@salpetriere)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/#post-6895463)
 * Thanks ganddser, but the list markup is still incorrect.
 * You made the correct changes I mentioned above, but you also changed some li 
   tags (to uls) that needed to stay as is.
 * You’ll need to amend the plugin again.
 * In joan.php line 176 needs to be changed to the below.
 * `$output .= '<li><strong>'.$startClock.'</strong> - <strong>'.$endClock.'</strong
   >: '.$showName.'</li>';`
 * Also on line 223 I missed a closing ul tag which we’ll need to add, as below.
 * `$output .= '</ul>';`
 *  Plugin Author [ganddser](https://wordpress.org/support/users/ganddser/)
 * (@ganddser)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/#post-6895466)
 * Thanks
 *  Thread Starter [Salpetriere](https://wordpress.org/support/users/salpetriere/)
 * (@salpetriere)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/#post-6895468)
 * Thanks for everything gandsser.
 * As you’ve advised, I’d like to look into your hosting. Do you have a test/dev
   WordPress site set up on it that I could log into and have a look around? I’d
   like make sure that everything works the way I need it to before moving forward.

Viewing 15 replies - 1 through 15 (of 27 total)

1 [2](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/page/2/?output_format=md)

The topic ‘Plugin Causing Javascript Error in WordPress Admin’ is closed to new 
replies.

 * ![](https://ps.w.org/joan/assets/icon.svg?rev=2874850)
 * [Jock On Air Now (JOAN)](https://wordpress.org/plugins/joan/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/joan/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/joan/)
 * [Active Topics](https://wordpress.org/support/plugin/joan/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/joan/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/joan/reviews/)

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [json](https://wordpress.org/support/topic-tag/json/)

 * 27 replies
 * 2 participants
 * Last reply from: [ganddser](https://wordpress.org/support/users/ganddser/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/plugin-causing-javascript-error-in-wordpress-admin/page/2/#post-6895500)
 * Status: resolved