Skip to content

Instantly share code, notes, and snippets.

@benjgorman
Created February 23, 2011 17:34
Show Gist options
  • Save benjgorman/840774 to your computer and use it in GitHub Desktop.
Save benjgorman/840774 to your computer and use it in GitHub Desktop.
The JSON returns fine however when this.Following has the value of "true"(string) and then comparing it to test 2, the else statement is called. Can you see any reason why?
$(function() {followLoad();});
function followLoad ()
{
$.getJSON("/Twitzer/Author/<%=Author.getuserName()%>/json", function(json)
{
var test="true";
var test2=this.Following;
if (test2==test)
{
$("#followButton").append('<button id="unfollow">Unfollow</button>');
}
else
{
$("#followButton").append('<button id="follow">Follow</button>');
}
});
}
@benjgorman
Copy link
Author

$(function() {followLoad();});
function followLoad ()
{
$.getJSON("/Twitzer/Author/<%=Author.getuserName()%>/json", function(json)
{
var test="true";
var test2=json.Following;

        if (test2==test)
        {
            $("#followButton").append('<button id="unfollow">Unfollow</button>');
        }
        else
        {
            $("#followButton").append('<button id="follow">Follow</button>');
        }

      });

}

@benjgorman
Copy link
Author

Above is the solution to the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment