阅读背景:

可以在PHP ajax中输入新行,并且无法在sendRequest()方法中请求预期日期

来源:互联网 
<?php
$myFile = "Wishes.txt";

$fh = fopen($myFile, 'w') or die("can't open file");
$mystring= $_POST["name"];
fwrite($fh, $mystring."\n\r");
fclose($fh);
?>  

<!DOCTYPE html>
<html>
        <head>
                <title>Wish well</title>
                <script language="javascript">

                        function sendtoajax(form)
                        {
                                var xmlhttp;
                                var content;
                                content=form.wish.value;

                                xmlhttp=new XMLHttpRequest();
                                xmlhttp.onreadystatechange=function()
                                  {
                                  if (xmlhttp.readyState==4 && xmlhttp.status==200)
                                  {
                                alert('done')
                                 }
                                }
                                xmlhttp.open("POST","ajax.php",true);
                                xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
                                xmlhttp.send("form.text.value");
                        }
                </script>
        </head>
        <body style="background-color:red;">

                <form name="Text">
                            Text<input type="text" name="text"/>
                            <input type="button" class="button" value="Throw In" onclick="sendtoajax(this.form)"/>
                            <input type="reset" value="Cancel"/>
                </form>
        </body>
</html>
<?php
$myFile = "Wishes.txt";

$fh = fopen($myF



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: