Here is my form.html

<html>
    <head>
        <script type="text/javascript">
            function ajax() {
                var aj;
                if(window.XMLHttpRequest) {
                    aj = new XMLHttpRequest();
                }
                else {
                    aj = new ActiveXObject("Microsoft.XMLHTTP");
                }

                aj.onreadystate = function() {
                    if(aj.ready == 4) {
                        document.getElementById("text").innerHTML = aj.responseText;
                    }
                };
                var param = document.forms["fo"]["text"].value;
                aj.open("GET", "try.php" , true);
                aj.send();
            }
        </script>
    </head>
    <body>
        <form name="fo" method="post">
            <input type="text" name="text" />
            <input type="submit" onsubmit="ajax()" name="submit" />
        </form>
        <p id="text">
        </p>
    </body>
</html>

Here is my try.php:

<?php 

    echo "this this working";
?>

How come i am not getting a responce back ?

Its still not working:

<html>
    <head>
        <script type="text/javascript">
            function ajax() {
                var aj;
                if(window.XMLHttpRequest) {
                    aj = new XMLHttpRequest();
                }
                else {
                    aj = new ActiveXObject("Microsoft.XMLHTTP");
                }

                aj.onreadystatechange= function() {
                    if(aj.readyState == 4) {
                        document.getElementById("text").value = aj.responseText;
                    }
                };

                aj.open("GET", "try.php" , true);
                aj.send(null);
            }
        </script>
    </head>
    <body>
        <form name="fo" method="post">
            <input type="text" name="text" />
            <input type="submit" onsubmit="ajax()" name="submit" />
        </form>
        <span id="text"> </span>
    </body>
</html>

Try to check out ahahLib.js :) you can find easly online!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.