Question

I tried to implement persona in my site but i don't get it to work.

<body>

<a href="" class="login">login</a>
    <script src="https://login.persona.org/include.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script>
    $(function() {
    $('#login').click(function(e){ navigator.id.request(); });
    $('#logout').click(function(e){ navigator.id.logout(); });
    navigator.id.watch({
        loggedInUser: null,
        onlogin: function(assertion) {
            $.post(
                '/auth.php',
                {assertion:assertion},
                function(msg) { console.log('login success!') }
            );
        },
        onlogout: function() {
            $.post(
                '/auth.php',
                {logout:1},
                function(msg) { console.log('logout success!') }
            );
        }
    });
});


    </script>
</body>

Here is a fiddle: http://jsfiddle.net/cMeUp/ but i don't even get a popup.

Do you guys know anything thats wrong with it?

Greetings

Was it helpful?

Solution

in your code your using login as a class not as an id

your code:

<a href="" class="login">login</a>
$('#login').click(function(e){ navigator.id.request(); });

try:

<a href="" id="login">login</a>

as you are using $('#login') as a selector.

here's a working JSFiddle

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top