通过XMLHttpRequest表单提交

I want to use XMLHttpRequest, to get the remote PHP file's response and display it on my page.

My problem, of course: The form's data isn't being submitted to that remote PHP page.

How do I make that happen? Thanks.

<form name="creation" action="" method="post">

E-mail: 
<input required type="text" name="emailCreation" onchange="emailValidate();" 
onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();">
<span id="emailRegexJavascriptResponse"></span>
<br>

Username: <input required type="text" name="userCreation" onchange="userValidate();" 
onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();">
<span id="userRegexJavascriptResponse"></span>
<br>

Password: <input required type="text" name="passwordCreation" onchange="passwordValidate();" 
onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();">
<span id="passwordJavascriptResponse"></span>
<br>

<input type="button" value="Submit" onclick="creationResult();">


<div id="here"></div><div id="here2"></div>

<!-- End -->


<script type="text/javascript">



function creationResult() {

    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    } else { // code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
        xmlhttp.onreadystatechange=function() {

            if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            document.getElementById("here").innerHTML=xmlhttp.responseText;
            }
        }
  xmlhttp.open("POST","accountcreation.php",true);
  xmlhttp.send();
}

1个回答



您必须通过您在函数调用 xmlhttp.open(“POST”中指定的URL)发送一些数据, “accountcreation.php”,true); </ code> </ p>

通过以下链接可以看到处理相同类型问题的帖子
http://www.csnotes32.com/2014/09/sample-code-for-check- availability.html </ p>
</ div>

展开原文

原文

You have to send some data through the URL that you are specifying in the function call xmlhttp.open("POST","accountcreation.php",true);

A posting which handles same type of problem can be seen by followin the link http://www.csnotes32.com/2014/09/sample-code-for-check-availability.html

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐