0

Just want to call a login function once after someone clicks a video thumbnail. This is what I have:

if (videoCode == "BQXTCCyJsKE" && $secCode == null){
var $secCode = "1";
$(document).ready(function () {
  login() 
});
}

You would think $secCode would equal "1" later on, but NO. It becomes null again and the login function is called again which gives an error. I've tried making global variables but it doesn't work. Anyone have any ideas?

  • http://stackoverflow.com/questions/500431/javascript-variable-scope – fionbio Feb 06 '13 at 06:06
  • I've tried the global scopes from that article but nothing works. Maybe facebook dedicated variable could help me like if(loggedIn). At this point, 8 hours into this, I'm open to any ideas. – Daniel Claire Feb 06 '13 at 06:47

1 Answers1

0

Writing in the answer box for better formatting, here is what I would have expected:

var secCode = null;  // I am global

if (videoCode == "BQXTCCyJsKE" && secCode == null){
    secCode = "1";
    $(document).ready(login());
}
fionbio
  • 3,368
  • 2
  • 23
  • 38
  • Even with that change, secCode returns to null and the login function is initiated again which produces an error. However, I do appreciate your help. – Daniel Claire Feb 06 '13 at 07:23
  • Change secCode to secCode123 for this portion of your logic and see if it works, so I know its not being changed elsewhere. I'm assuming you didn't set secCode = null right above the conditional, but once at doc start? – fionbio Feb 06 '13 at 07:28
  • Changing the code to var secCode = "123"; stopped the login altogether. This statement is just under the top body tag. – Daniel Claire Feb 06 '13 at 07:40