WEB Can one of you javascript guys show me how to do this real quick

Discussion in 'OT Technology' started by 95vr4, Jan 4, 2008.

  1. 95vr4

    95vr4 OT Supporter

    Joined:
    Oct 6, 2004
    Messages:
    2,513
    Likes Received:
    0
    Location:
    Weddington, NC
    Trying to get this little prototype ajax login working, I know it's not posting to the asp page and can't figure out why. Their source code for their demo is just programmed to always say incorrect password. (http://prototype-window.xilinus.com/samples.html) <-- #7

    Need to figure out how to make function openConfirmDialog() check the login and get a response

    My asp page is http://mojo3120.com/modal/loginexec.asp
    Code:
    <%
    pName=request.QueryString("username")
    pPass=request.QueryString("password")
    if pName="abc" and pPass="abc" then
    response.write "yes"
    else
    response.write "no"
    end if%>
    
    And the html page is http://mojo3120.com/modal/test.html
    Code:
    <html>
    <head>
    <script type="text/javascript" src="javascripts/prototype.js"></script> 
    <script type="text/javascript" src="javascripts/effects.js"></script>
    <script type="text/javascript" src="javascripts/window.js"></script>
    <script type="text/javascript" src="javascripts/window_effects.js"></script>
    
    <link href="themes/default.css" rel="stylesheet" type="text/css" ></link>
    <link href="themes/spread.css" rel="stylesheet" type="text/css" ></link>
    <link href="themes/alphacube.css" rel="stylesheet" type="text/css" ></link>
    </head>
    <body>
    
    <div id="login" style="display:none">
    <form id="loginfrm" name="loginfrm" method="post">
      <table width="96%" border="0" align="center" cellpadding="0" cellspacing="1">
        <tr>
          <td width="100">Username:</td>
          <td><input name="username" type="text" class="borders" id="username" /></td>
        </tr>
        <tr>
          <td>Password:</td>
          <td><input name="password" type="text" class="borders" id="password" /></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
      </table>
    </form>
    </div>
    
    
    
    
    <a href="javascript:openConfirmDialog()">login</a>
    <br>
    
    <script>
    
        function openConfirmDialog() {Dialog.confirm($('login').innerHTML, {className:"alphacube", width:400, okLabel: "login", cancelLabel: "cancel", onOk:function(win){ $('login_error_msg').innerHTML='Login or password inccorect'; $('login_error_msg').show(); Windows.focusedWindow.updateHeight(); new Effect.Shake(Windows.focusedWindow.getId()); return false;}});
        }
    
    
    Not sure what I'm doin here :hsugh:
    [code]
    /*
    function loginChk()
    {
     var t = new Ajax.Request( 'loginexec.asp', {
        parameters: $('loginfrm').serialize(),
        method: 'post',
        onSuccess:alert(t.responseText) } )
        
            return false;
    }
    
    
    ;}
    */
    </script>
    
    </body>
    </html>
    [/code]
     
  2. ez4me2c3d

    ez4me2c3d Cold Member

    Joined:
    Sep 19, 2003
    Messages:
    1,836
    Likes Received:
    0
    Location:
    Minneapolis, MN
    You are checking for Request.QueryString which is a GET method

    But in your AJAX call you are specifying POST as the method

    So it's probably sending it, but you are looking in the wrong place for it.

    Either change your Request.QueryString to Request.Form or change your method: 'post' to method: 'get'

    EDIT: Changed my "Response" to 'Request"

    EDIT2: Actually there appears to be more wrong with it than just that, I'm taking a look.
     
    Last edited: Jan 4, 2008
  3. 95vr4

    95vr4 OT Supporter

    Joined:
    Oct 6, 2004
    Messages:
    2,513
    Likes Received:
    0
    Location:
    Weddington, NC
    :wavey: Thanks. You're right about the asp page. I know it wasn't posting to it tho bc I logged in and checked the server logs. I know it's not working as it is now bc the only thing that even attempts to make a request is commented out
     
  4. TheDarkHorizon

    TheDarkHorizon \xC0\xFF\xEE

    Joined:
    Sep 26, 2002
    Messages:
    2,396
    Likes Received:
    0
    Location:
    San Francisco, CA
    You are trying to get an element with ID 'login_error_msg', but you never created one.

    EDIT: See the markup in #7 of the example page you provided.
     
  5. ez4me2c3d

    ez4me2c3d Cold Member

    Joined:
    Sep 19, 2003
    Messages:
    1,836
    Likes Received:
    0
    Location:
    Minneapolis, MN
    Alright so a few things...

    That script sucks balls and you should walk away from it right now. It's more of a pain in the ass than it's worth. I can't believe I put enough effort into it to hack it together for you either. ugh

    With that said, I have it working, but it's not very pretty. It would need A LOT more tweaking before going into production, but I have it working.

    The only file you can't see is my check-login.php file:
    Code:
    <?=($_GET['u'] == 'abc' && $_GET['p'] == 'abc') ? '0' : '1'?>
    Otherwise view source on this page: http://avholloway.com/sandbox/win/

    username/password = abc/abc
     
  6. 95vr4

    95vr4 OT Supporter

    Joined:
    Oct 6, 2004
    Messages:
    2,513
    Likes Received:
    0
    Location:
    Weddington, NC
    :wiggle: Thanks man, I owe u one. It's not going into a production, just trying to learn prototype and ajax :hsd:
     
  7. ez4me2c3d

    ez4me2c3d Cold Member

    Joined:
    Sep 19, 2003
    Messages:
    1,836
    Likes Received:
    0
    Location:
    Minneapolis, MN
    ew then don't follow that crap for your starter scripts... take a look at the prototype API Doc, it's really good.

    did you notice how I had to hard code the form elements in the JS function? that's because that shitty windows script duplicates the form so when you try and get the values from the form fields, you end up with two forms with the sam e name and id, and it can't find the right values.

    but, you're welcome, glad I could help, but not glad i did help. that was painful to mess with.
     

Share This Page