Search code examples
phpjavascriptfacebookfbmlfbjs

Javascript functions not working / giving errors in my iFrame based app on Facebook!


I have a iFrame based app on Facebook which does what its supposed to. Its PHP-based. However, as soon as I put some Javascript function, it stops working at all!

What I am initially trying to do is to see if I have authorization for the user. If I dont have it, I send the user to the authorization page of facebook. Here's the code:

<script>
    function submitMappingForm() //for mapping 
    { 
        // declare a new FBJS AJAX object
        //var ajax = new Ajax(); 
        //ajax.responseType = Ajax.FBML;

        // define a callback to handle the response from the server
        //ajax.ondone = function(data) 
        //{ 
            //document.getElementById('stat').setInnerFBML(data);
        //}

        // let the user know we're sending the data 
        //document.getElementById('stat').setInnerXHTML('Submitting your information, please wait...');

        // collect field values
        var queryParams = { 'uname' : document.getElementById('uname').getValue(), 'upass' : document.getElementById('upass').getValue(), 'user_id' : document.getElementById('userID').getValue() };
        ajax.post('http://abcd.com/efg.php', queryParams);
        return true;
    }
</script>Welcome!<script> top.location.href='http://www.facebook.com/dialog/oauth?client_id=123456789&redirect_uri=http%3A%2F%2Fapps.facebook.com%2Fsomeapp%2F'</script>

However, I am getting an error with this script in firefox which is:

Error: document.getElementById("uname").getValue is not a function
Source File: <some page>
Line: 19

Can anyone kindly let me know what I am doing wrong here ?

Thanks.

- ahsan


Solution

  • Your first closing script tag is spelt incorrectly. </scrpt>