The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Uncaught ReferenceE...
 
Share:
Notifications
Clear all

Uncaught ReferenceError: wpdiscuzAjaxObj is not defined

5 Posts
3 Users
0 Reactions
1,546 Views
Posts: 2
Topic starter
(@colt0356)
New Member
Joined: 4 years ago

Hello, im trying to Lazy Load Wpdiscuz. So i first dequeue the wpdiscuz-combo.min.js in my functions.php and then i made another script to load the script 2 seconds after everything is loaded in the website.

However when the script is loaded i get the error Uncaught ReferenceError: wpdiscuzAjaxObj is not defined

 

How can i fix this?

4 Replies
Asti
Posts: 7661
 Asti
Support
(@asti)
Illustrious Member
Joined: 7 years ago

Hi@colt0356,

Simply you should load (enqueue) the wpdiscuzAjaxObj with the js file. 

Reply
Posts: 2
Topic starter
(@colt0356)
New Member
Joined: 4 years ago

And how am i going to do that?

var wpdiscuzAjaxObj = "https://www.abnehmenclub.de/wp-content/plugins/wpdiscuz/utils/ajax/wpdiscuz-ajax.php";

 

doesnt work

Reply
1 Reply
Asti
 Asti
Support
(@asti)
Joined: 7 years ago

Illustrious Member
Posts: 7661

@colt0356,

wpdiscuzAjaxObj is a global object that includes all wpDiscuz options that necessary for using wpDiscuz js code. You've simply passed the URL, that's wrong. Please see how the object is used in wpDiscuz files and in the same way load (enqueue) it. 

In the code, the wpdiscuzAjaxObj is localized, so if you can find and load (enqueue) the object, it'll work fine. 

More info here: https://developer.wordpress.org/reference/functions/wp_localize_script/

Reply
Posts: 1
(@larryhems)
New Member
Joined: 3 years ago

If you are using any script file and getting "Uncaught ReferenceError: 'wpdiscuzAjaxObj' is not defined " which means ‘wpdiscuzAjaxObj’ is either a variable or a method which you are trying to use before declaring it using var keyword. This means that there is a non-existent variable referenced somewhere. This variable needs to be declared, or you need to make sure it is available in your current script or scope otherwise , it will endup throwing this ‘wpdiscuzAjaxObj’ is not defined error . This usually indicates that your library is not loaded and JavaScript does not recognize the ‘wpdiscuzAjaxObj’.

To solve this error: Load the jQuery CDN library at the beginning of all your javascript files/scripts which uses $/ jQuery, so that $/jQuery can be identified in scripts .

There can be multiple other reasons for this issue:

  • Conflict with Other Libraries
  • Path to your library included is not correct
  • Llibrary file is corrupted
  • Working offline (when you use CDN)

 

Reply
Share: