inherit
203080
0
Mar 17, 2014 14:50:56 GMT -8
baratheon
43
December 2013
baratheon
|
Post by baratheon on Dec 25, 2013 18:07:34 GMT -8
My plugin is producing the error "Cannot Read Property 'Length' Of Null", however, I reviewed the code, and there is no line in the script that calls for the length of any property (the keyword "length" just doesn't appear anywhere). Any ideas what might be causing this?
Thanks.
|
|
#00AF33
Bark Different.
102833
0
1
Feb 12, 2023 16:57:46 GMT -8
RedBassett
I'm a Marxist/Lennonist of the Groucho/John variety.
15,405
April 2007
applecomputer
RedBassett's Mini-Profile
|
Post by RedBassett on Dec 25, 2013 21:50:02 GMT -8
The length call may be made inside a function you are calling. Any chance you can link to an example of the plugin?
|
|
inherit
203080
0
Mar 17, 2014 14:50:56 GMT -8
baratheon
43
December 2013
baratheon
|
Post by baratheon on Dec 26, 2013 11:42:12 GMT -8
|
|
inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Dec 26, 2013 12:53:38 GMT -8
prepend 0 in case... I'm not seeing that error but this looks like it should be commented.
|
|
inherit
203080
0
Mar 17, 2014 14:50:56 GMT -8
baratheon
43
December 2013
baratheon
|
Post by baratheon on Dec 26, 2013 13:47:23 GMT -8
Oops, you're right. I've had it commented out previously and must have accidentally uncommented it at some point.
Somehow it fixed the error I was having with the null property. Thanks.
|
|
#00AF33
Bark Different.
102833
0
1
Feb 12, 2023 16:57:46 GMT -8
RedBassett
I'm a Marxist/Lennonist of the Groucho/John variety.
15,405
April 2007
applecomputer
RedBassett's Mini-Profile
|
Post by RedBassett on Dec 26, 2013 14:59:29 GMT -8
Glad to hear the issue is resolved.
|
|
inherit
203080
0
Mar 17, 2014 14:50:56 GMT -8
baratheon
43
December 2013
baratheon
|
Post by baratheon on Dec 26, 2013 22:14:44 GMT -8
Sadly, it looks like the problem arose again. Same error: testforum1995.freeforums.net/Also, a prompt that says "Congratulations to ___ for winning..." isn't displaying - that's probably correlated with the problem. I've been combing through the code, but I wasn't able to find anything.
|
|
#00AF33
Bark Different.
102833
0
1
Feb 12, 2023 16:57:46 GMT -8
RedBassett
I'm a Marxist/Lennonist of the Groucho/John variety.
15,405
April 2007
applecomputer
RedBassett's Mini-Profile
|
Post by RedBassett on Dec 27, 2013 3:33:04 GMT -8
Here is my guess:
//prepend 0 in case... $.each(formatDate, function(key, val){ var temp_key = key; if(temp_key.length < 2){ key = '0' + key; } }); $.each(formatTime, function(key, val){ var temp_key = key; if(temp_key.length < 2){ key = '0' + key; } });
You are calling the length property of the key, not the value. Is this what you intend to do? If I try to call the length of the key, I get "undefined".
|
|
inherit
203080
0
Mar 17, 2014 14:50:56 GMT -8
baratheon
43
December 2013
baratheon
|
Post by baratheon on Dec 27, 2013 10:57:03 GMT -8
You're right. I did mean to call for the value instead of the key, but even with that fixed I continue to get the error. I tried to comment out the whole part, but the problem still persists.
I found that, the error occurs only when pb.plugin.get('raffle_center').settings.raffle_event is set to true, AND the timer has ended.
|
|
inherit
203080
0
Mar 17, 2014 14:50:56 GMT -8
baratheon
43
December 2013
baratheon
|
Post by baratheon on Dec 27, 2013 11:34:18 GMT -8
Alright, another hint: the error will only occur when the conditions above are met, AND there are no participants (meaning, the all_entries key and winner key will be empty/undefined)
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,017
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Dec 27, 2013 14:23:45 GMT -8
Alright, another hint: the error will only occur when the conditions above are met, AND there are no participants (meaning, the all_entries key and winner key will be empty/undefined) Most jQuery documentations usually reflect the behavior of the latest release and not necessarily behavior that may have been present in previous releases but the following snippet when viewed with the knowledge that Proboards currently uses jquery version 1.7.2 means the error could be coming from the returned value of parseJSON if (pb.plugin.key('winner').get() == undefined || pb.plugin.key('winner').get() == '') { if (pb.plugin.key('all_entries').get() != undefined || pb.plugin.key('all_entries').get() != '') { var get_all_entries = pb.plugin.key('all_entries').get(); var all_entriesObj = $.parseJSON(get_all_entries); var rand_num = Math.floor(Math.random() * all_entriesObj.length); //determine prize var final_prize; ...
Two other similar lines using parseJSON exist and the behavior prior to v1.9 of the jQuery library was to return null if what was being parsed was undefined, null or an empty string. This then means the all_entriesObj variable could conceivably be null and getting the length of this variable would produce an error very similar to what was quoted. It should also be noted that depending on the browser, the jquery library might even defer to the native (quicker) JSON.parse implementation rather than its own causing that particular error to occur in one browser yet not another. It would therefore be wise to verify that value before passing it on to parseJSON since native browser and later jquery implementations opt to throw a syntaxError instead plus one day Proboards will throw the switch and upgrade to a newer library release
|
|
inherit
203080
0
Mar 17, 2014 14:50:56 GMT -8
baratheon
43
December 2013
baratheon
|
Post by baratheon on Dec 28, 2013 9:37:44 GMT -8
Thanks. I looked over the code and added an if statement in case the value of all_entries was empty. Now it works fine.
|
|