Title: Javascript error on frontend.js
Last modified: August 30, 2016

---

# Javascript error on frontend.js

 *  [Sandra Sanz](https://wordpress.org/support/users/sandra-sanz/)
 * (@sandra-sanz)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/javascript-error-on-frontendjs/)
 * The plugin seems to work fine overall but the javascript console raises the following
   error in every page where the banners are displayed: `Uncaught TypeError: Cannot
   read property 'left' of undefined - frontend.js line 44`.
 * This is the function that is causing the error (third line):
 *     ```
       function logging_ads(){
   
       	$('.aas_wrapper').each(function(){
       		if( isVisible( jQuery(this).children() ) && jQuery(this).offset().left == jQuery(this).closest('.caroufredsel_wrapper').offset().left && viewed[jQuery(this).data('ads')] != 1 ){
       		viewed[jQuery(this).data('ads')] = 1;
       		var data = {
       		action : 'aas_view_log',
       		nonce : jQuery(this).data('nonce'),
       		data : jQuery(this).data('ads'),
       		c_url : window.location.href
       		};
       		jQuery.post(ajax.url,data,function(response){});
       		}
       	});
       }
       ```
   
 * Any ideas of what can be the reason and how to correct it? Otherwise great plugin,
   very simple to use in comparison to other advertising plugins.
 * This is the website I’m working on: [http://indumentat.com/](http://indumentat.com/)
 * [https://wordpress.org/plugins/advanced-advertising-system/](https://wordpress.org/plugins/advanced-advertising-system/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [smartdevth](https://wordpress.org/support/users/smartdevth/)
 * (@smartdevth)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/javascript-error-on-frontendjs/#post-6500029)
 * Perhaps, the caroufredsel wrapper didn’t exist because the error you’ve shown
   noticed that getting offset() of undefined.
 * Did any js errors occur before mine?
 * I will deeply check your site when Im home.
 * Best regard,
    Smartdevth
 *  Thread Starter [Sandra Sanz](https://wordpress.org/support/users/sandra-sanz/)
 * (@sandra-sanz)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/javascript-error-on-frontendjs/#post-6500040)
 * Thanks for answering!
 * This is weird, I swear yesterday there was only that error again and again (it
   seemed to happen every time a banner would rotate, because they stacked in the
   console as time went by) but now it only happens every now and then and when 
   it happens, it does only once.
 * There’s another javascript error happening in the frontpage sometimes that is`
   cannot call methods on isotope prior to initialization; attempted to call 'layout'`
   but that seeems to be unrelated to the plugin, they’re template functions.
 * It could be related to caroufredsel not loading properly yesterday for some reason
   and now it only happens if for some reason the plugin functions load and start
   before the caroufredsel functions have loaded.
 * In short I can’t put my finger on what and when it’s failing and it doesn’t seem
   to cause any problems so… I’ll get back to you if I collect any more info.
 *  [Ovejabeja](https://wordpress.org/support/users/ovejabeja/)
 * (@ovejabeja)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/javascript-error-on-frontendjs/#post-6500367)
 * I’m the same person, I don’t have access to my other account right now.
 * I noticed the error just happens when there’s an ad where both the featured image
   and the extended html field are left blank. When I first wrote this message, 
   it didn’t seem to cause any major issues, but later it happened to break several
   plugins that used javascript.
 * I think the issue is caused in the isVisible() function, when it tries to get
   the left and top offset of the empty ad.
 * I guess empty ads shouldn’t exist, but if this issue is reproducible in other
   environments I think it should be bulletproofed just in case. I think my clients
   delete old images pertaining to old ads that they think they don’t have use for
   anymore, and that’s when it breaks.
 *  Plugin Author [smartdevth](https://wordpress.org/support/users/smartdevth/)
 * (@smartdevth)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/javascript-error-on-frontendjs/#post-6500368)
 * Ok, I will improve isVisible function to check if there is empty ad.
 *  [Ovejabeja](https://wordpress.org/support/users/ovejabeja/)
 * (@ovejabeja)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/javascript-error-on-frontendjs/#post-6500369)
 * Great! 🙂

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Javascript error on frontend.js’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/advanced-advertising-system_e3e4e3.
   svg)
 * [Advanced Advertising System](https://wordpress.org/plugins/advanced-advertising-system/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-advertising-system/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-advertising-system/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-advertising-system/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-advertising-system/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-advertising-system/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [Ovejabeja](https://wordpress.org/support/users/ovejabeja/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/javascript-error-on-frontendjs/#post-6500369)
 * Status: not resolved