0

I am just starting to load ajax. Whats supposed to happen is when you click on the submit button, the contents of a php file will be put in the paragraph. The problem is that it ouputs undefined. Here is the code:

ajax.php

<html>

    <head>
        <title>Welcome to our ajax page</title>

        <script type = "text/javascript">
            function ajax()
            {
                var r;
                if(window.XMLHttpRequest)
                {
                    r = new XMLHttpRequest();
                }

                else
                {
                    r = new ActiveXObject('Microsoft.XMLHTTP');
                }

                r.onreadystatechange = function() {

                    if(r.readyState == 4 && r.status == 200) {
                        document.getElementById("pt").innerHTML = r.responceText;
                    }

                }
                r.open('GET','include.inc.php',true);
                r.send();
            }   
        </script>

    </head>

    <body>

        <noscript>
            <h3>You need JavaScript enabled to view this page</h3>
        </noscript>



        <input type = "submit" onclick="ajax();" >
        <div id="adiv"><p id = "pt"></p></div>

    </body>

</html>

include.inc.php

<?php echo "hello world"; ?>

Edited by godzab

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by godzab
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.