开发者

What is wrong with my script?

I don't see any errors in Firebug, and I can't figure out what's wrong with the AJAX.

PHP:

<?php


$subject = $_POST['subject'];

echo $subject;



?>

Javascript

  <html>
<head>
<script type="text/javascript">
/* <![CDATA[ */ 

    function ajax() {


        if (window.XMLHttpRequest) {
            xmlhttp=new XMLHttpRequest();           
        } else {
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }

        xmlhttp.onreadystatechange=function() {
            if (xmlhttp.readyState == 4 && xmlhttp.stat开发者_Go百科us == 200) {
                document.getElementById("result_div").value = xmlhttp.responseText;
            }
        }
        xmlhttp.open("POST","message.php",true);
        xmlhttp.send();

        return false;
    }

    /* ]]> */ 
</script>
</head>
<body>
<div id="result_div"></div>
<form action="" onsubmit="return ajax();">

    <select name="teest">
        <option value="hi">hi</option>
    </select><br />

    <input type="text" name="subject"> <br />
            <input type="submit">

</form>

</body>
</html>


You are not POSTing anything. When using ajax forms are not handled automatically for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜