junaidh junaidh - 1 month ago 6
Javascript Question

uncaught syntax error unexpected end of input (java script)

the last line is show error

(function login() {
FB.login(function(response) {
if (response.status === 'connected') {
getElementById('status').innerHTML = 'we are connected.';
} else if (response.status === 'not authorized') {
document.getElementById('status').innerHTML = 'we are not logged in.'
} else {
document.getElementById('status').innerHTML = 'you are not logged into facebook.';
}
});
}

Answer

there seems multiple issues with the code

  1. Your first call to getElementById is a error. You should be calling it on document object.
  2. Add a ); at the end

Your code will look like

(function login() {
    FB.login(function(response) {
        if (response.status === 'connected') {
            document.getElementById('status').innerHTML = 'we are connected.';
        } else if (response.status === 'not authorized') {
            document.getElementById('status').innerHTML = 'we are not logged in.'
        } else {
            document.getElementById('status').innerHTML = 'you are not logged into facebook.';
        }
    });
});