Form Post method not working on mac

Discussion in 'Web Design and Development' started by NWL, Jan 20, 2011.

  1. NWL macrumors newbie

    Joined:
    Jan 20, 2011
    #1
    I have this simple asp page that does a post to a different site with the user credentials. This works fine on PC and all browsers but does not work on the mac using Firefox. Basically on the mac all I get is a blank page and it never does the post. Below is the code any help would be great.


    Code:
    <html>
    <head>
    <title>Link</title>
    
    <script language=javascript type="text/javascript">
    
    <!--
    
    function getCookieValues( )
    {
        var values = [];
        var temp = document.cookie.split( /\;/g );
        for ( var c = 0; c < temp.length; ++c )
        {
            var pair = temp[c].split("=");
            var name = pair[0].replace(/^\s+/,"").replace(/\s$/,"");
            if ( name == "UserIDPW") {
               var val = pair[1].split("&");
               return [ unescape(val[0]),
                        unescape(val[1]) ];
            }
        }
        return null;
    }
    function getUserIDPWcookie( )
    {
    var both = getCookieValues( );
        if ( both != null ) 
        {
            var frm = document.LinkForm;
            frm.Account_ID.value = both[0];
            frm.Account_Password.value = both[1];
            frm.submit();
        }
    }
    
    //        alert(   "\nusername: " + id[0]
    //              + "\npassword: " + pw[1] );
    //   }
    
    //-->
    </SCRIPT>
    
    
    
    <body onLoad="getUserIDPWcookie();" >
    
    
    <form method="POST" action="http://server1btest.ccc.com/TST/com/check.asp" name="LinkForm" ><br>
    <input type='hidden' name='Account_ID' value=""><br>
    <input type='hidden' name='Account_Password' value="'pw'"><br> 
    
    
    </form>
    </body>
    </html>
    I have tried stripping everything done to just the form post but it still does not work.
     
  2. harpster macrumors regular

    Joined:
    Jan 26, 2010
    #2
    This probably isn't it but I noticed you don't have a </head> tag.
     
  3. NWL thread starter macrumors newbie

    Joined:
    Jan 20, 2011
    #3
    I added the tag but that did not help. Thanks for the reply though. :)
     
  4. Ygn macrumors member

    Joined:
    Aug 8, 2010
    #4
    Theres a couple of things, like the person above said you don't have a </head> tag, also the attribute 'language' isn't valid I don't think, plus you wouldn't need to define javascript if you already have type="text/javascript".

    Done it for you:
    Code:
    <html>
    <head>
    <title>Link</title>
    
    <script type="text/javascript">
    
    <!--
    
    function getCookieValues( )
    {
        var values = [];
        var temp = document.cookie.split( /\;/g );
        for ( var c = 0; c < temp.length; ++c )
        {
            var pair = temp[c].split("=");
            var name = pair[0].replace(/^\s+/,"").replace(/\s$/,"");
            if ( name == "UserIDPW") {
               var val = pair[1].split("&");
               return [ unescape(val[0]),
                        unescape(val[1]) ];
            }
        }
        return null;
    }
    function getUserIDPWcookie( )
    {
    var both = getCookieValues( );
        if ( both != null ) 
        {
            var frm = document.LinkForm;
            frm.Account_ID.value = both[0];
            frm.Account_Password.value = both[1];
            frm.submit();
        }
    }
    
    //        alert(   "\nusername: " + id[0]
    //              + "\npassword: " + pw[1] );
    //   }
    
    //-->
    </script>
    </head>
    
    
    <body onLoad="getUserIDPWcookie();" >
    
    
    <form method="POST" action="http://server1btest.ccc.com/TST/com/check.asp" name="LinkForm" ><br>
    <input type='hidden' name='Account_ID' value=""><br>
    <input type='hidden' name='Account_Password' value="'pw'"><br> 
    
    
    </form>
    </body>
    </html>
    
     
  5. NWL thread starter macrumors newbie

    Joined:
    Jan 20, 2011
    #5
    Thanks for the corrections and the help. I tried the code above but still get the same issue. Basically Firefox on the mac just says done but never post the information or error out.
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    What are you expecting to appear? You have a form with two hidden inputs.
     
  7. Ygn macrumors member

    Joined:
    Aug 8, 2010
    #7
    That's really weird how it's not working on firefox mac but on other browsers it is.. it's probably something really small but I'm useless at Javascript!

    Would it be this line?
    <input type='hidden' name='Account_Password' value="'pw'"><br>

    With the single and double quotations.. try this maybe?

    <input type='hidden' name='Account_Password' value="pw"><br>
     
  8. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #8
    Well, in the function where it will be submitted, you check if the variable both is null. Perhaps it is null. Then the issue would be in the parsing of the cookie in the other function. Use some alert statements or console logs to get a the information. Or you could also use Firebug to debug the code as it is being executed. When I tested locally, both was null.
     
  9. NWL, Jan 20, 2011
    Last edited by a moderator: Jan 20, 2011

    NWL thread starter macrumors newbie

    Joined:
    Jan 20, 2011
    #9
    It should post to the page http://server1btest.ccc.com/TST/com/check.asp with the user credentials.

    I believe you are correct. It looks like my cookie is not being passed on to the next firefox window for some reason not sure how to get it to pass the cookie on.
     
  10. YanniDepp macrumors 6502

    YanniDepp

    Joined:
    Dec 10, 2008
    #10
    Install Firebug. Its javascript console may provide some useful information.
     
  11. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #11
    Are you able to provide the code related to setting the cookie leading up to this page? Also check your Firefox preferences on the Privacy tab. There's settings for cookies such as whether to accept 3rd party cookies. I don't think this is a 3rd party cookie though. There's also a setting for how long to keep the cookie.
     
  12. NWL thread starter macrumors newbie

    Joined:
    Jan 20, 2011
    #12
    Here is the code that sets the cookie.

    Code:
    function setcookie ( cookie_name, cookie_value,lifespan_in_days, valid_domain )
    {
        var userid = document.forms[0].username.value;
        var userpw = document.forms[0].password.value;
        document.cookie = "UserIDPW=" + encodeURIComponent( userid ) 
                        + "&" + encodeURIComponent( userpw ) 
                        + "; path=/; domain=.ccc.com" ;
    }
     
  13. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #13
    I see the expiration is being set. It is optional, and should last until the user exits, but it might be a good idea to try and set it explicitly. Remember that it needs to be in GMT format.
    PHP:
    // Example
    var exp = new Date();
    exp.setTime(exp.getTime() + 1000*60*60*24*365); // one year
    document.cookie "..." ';expires='exp.toGMTString();
    Also try using the escape function rather than the encodeURIComponent function because you're using the unescape function in your other code so they don't match up.

    Other than that, using Firebug and walking through the code, or using some alert windows at various parts of your code is the only way to really get into it to see where the problem pops up.
     

Share This Page