Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder godofreality's Avatar
    Join Date
    Jan 2009
    Posts
    234
    Thanks
    1
    Thanked 15 Times in 15 Posts

    ajax not sending post data to server

    the form though at this point form values don't matter just the button

    Code:
    <div id="login" class="content" style="margin-top: 10px;">
    	<span class="titlebar">Deity Citadel Login</span>
    	<span class="form">Username:<input type="text" id="user" /></span>
    	<span class="form">Password:<input type="password" id="password" /></span>
    	<span class="menubutton" style="display: block; margin: auto; margin-top: 5px; margin-bottom: 5px;" onclick="handler2('login',this)">LOGIN</span>
    					</div>
    handler2 function

    Code:
    <script typ="text/javascript">
    	function handler2(action,src){
    		var breaker = new Date();
    		var info = 1;
    		var data = 4;
    		var debug = document.getElementById('debug');
    		debug.innerHTML = '';
    		var ajax = false;
    		if(window.XMLHttpRequest){
    			ajax = new XMLHttpRequest();
    		} 
    		else if(window.ActiveXObject){
    			ajax = new ActiveXObject("Microsoft.XMLHTTP");
    		}
    		if(ajax){
    			ajax.open("POST", 'handler.php?action='+action+'&breaker='+breaker.getTime());
    			ajax.setRequestHeader('Content-Type','application/x-www-output-urlencoded');
    			ajax.onreadystatechange = function(){
    				if(ajax.readyState == 4){
    					debug.innerHTML = ajax.responseText;
    				}
    			}
    		}
    		ajax.send('info='+info+'&data='+data);
    	}
    </script>
    and finally handler.php

    PHP Code:
    <?php
        session_start
    ();
        echo 
    'GET Array<br />';
        
    var_dump($_GET);
        echo 
    '<hr />POST Array<br />';
        
    var_dump($_POST);
    ?>
    my results are this:
    GET Array
    array(2) { ["action"]=> string(5) "login" ["breaker"]=> string(13) "1371746018997" }
    POST Array
    array(0) { }
    woot found the avatar options...i swear they didn't exist b4

  • #2
    Regular Coder godofreality's Avatar
    Join Date
    Jan 2009
    Posts
    234
    Thanks
    1
    Thanked 15 Times in 15 Posts
    nvm although i didn't find the solution i scrapped it moved on and won't be using this
    woot found the avatar options...i swear they didn't exist b4


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •