Javascript 关于提交问题的PHP Ajax Html

Javascript 关于提交问题的PHP Ajax Html,javascript,php,jquery,html,ajax,Javascript,Php,Jquery,Html,Ajax,因此,我有下面的代码,所有的工作,但成功/错误,我可以找到它 这是settings.php <li><button type="button" onclick="ApimanagementFunctioncall()" id="button1" class="btn btn-default btn-lg"><a href="#">Api management</button></a></li> <script>

因此,我有下面的代码,所有的工作,但成功/错误,我可以找到它

这是settings.php

<li><button type="button" onclick="ApimanagementFunctioncall()" id="button1" class="btn btn-default btn-lg"><a href="#">Api management</button></a></li>
<script>
    function ApimanagementFunctioncall(){
    var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
    if (xhttp.readyState == 4 && xhttp.status == 200) {
    document.getElementById("display").innerHTML = xhttp.responseText;
    }
    }
    xhttp.open("GET", "Apimanagement.php", true);
    xhttp.send();   
    }

    </script>
  • 函数ApimanagementFunctioncall(){ var xhttp=newXMLHttpRequest(); xhttp.onreadystatechange=函数(){ 如果(xhttp.readyState==4&&xhttp.status==200){ document.getElementById(“display”).innerHTML=xhttp.responseText; } } open(“GET”,“Apimanagement.php”,true); xhttp.send(); }
    apimagement.php

    这里是MySQLI表

    <div class="container">
        <div class="row text-left">
         <button type="button" class="btn btn-default btn-lg"  data-toggle="modal" data-target="#AddApi"><span class="glyphicon glyphicon-plus"></span>Add Api</button>
        </div>
    </div>
    
    <div class="modal fade" id="AddApi" role="dialog">
    <?php
    include ("ApiAdd.php");
    ?>
    </div>
    
    
    添加Api
    
    这是Addapi.php

    <?php
        $errorMessage = "";
        $UserId = "11";
    
         if(isset($_POST['submit'])){
           $VarKeyID = $_POST["KeyID"];
           $VarVCode = $_POST["VerificationCode"];
           $errorMessage1 = ""; 
           $errorMessage2 = "";
           $VkeyAdd= ""; $VCodeAdd = "";
            if(empty($VarKeyID) == false){
                if(is_numeric($VarKeyID) == true){
                    if(strlen($VarKeyID) !== 8){
                        echo '<script type="text/javascript">alert("Key Id is not the correct length of 8 numbers!\n");</script>';}
                        else{ $VKeyAdd = "true";}
                }else{$errorMessage1 = '<script type="text/javascript">alert("Key Id should only be numbers!");</script>';}
            }else{$errorMessage1 ='<script type="text/javascript">alert("Please Enter a Key ID!");</script>';}
    
            if(empty($VarVCode) == false){
                if(ctype_alnum($VarVCode) == true){
                    if(strlen($VarVCode) !== 64){
                        $errorMessage2 = "Verification Code should be 64 characters!";
                        }else{$VCodeAdd = "true";}              
                }else{$errorMessage2 = '<script type="text/javascript">alert("Verification Code should only be letters and numbers!");</script>';}
            }else{$errorMessage2 ='<script type="text/javascript">alert("Please Enter a Verification Code!");</script>';}
    
            If($VKeyAdd == "true"){
                if($VCodeAdd == "true"){
                echo "Next";}else{echo $errorMessage2;}
            }else{echo $errorMessage1;}
         }
    ?>
    
    <div  id="AddApi">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                <a href="Settings.php" title="Close" class="close"><span class="glyphicon glyphicon-remove"></span></a>
                <h2> Add Api Key </h2> 
                <a href="https://community.eveonline.com/support/api-key/CreatePredefined?accessMask=1073741823" target="_blank" class="btn btn-link" role="button">Api create key here</a>
                <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
                Key ID</br> <input type="text" name="KeyID" maxlength="8" value=""></br>
                Verification Code</br> <input type="text" name="VerificationCode" maxlength="64" min="64" value=""></br>
                <input type="submit" name="submit" value="Submit" formtarget="_Self">
                </form>
            </div>
        </div>
    <div>
    

    永远不要调用表单中的任何内容
    name=“submit”
    -这可能不是您的问题,但是如果您想使用脚本提交,请更改名称。还要在php中设置错误消息,并测试它是否为空,如果不是echo。使查看错误isI不希望脚本的位置变得更加容易,同时显示错误消息,并且在代码运行时不会出现任何错误。只是我不想这样。我真的不确定你说的是错的。你期待什么样的行为?这仅仅是因为当一切都正确时,它不会运行
    Settings.php
    ?您应该可以使用
    window.location.href=“Settings.php”来实现这一点
    标题(“位置:Settings.php”)。您的代码太复杂了。写一张什么叫什么的图表。现在,当您使用jQuery$.get和$.post处理与服务器的所有通信时,您正在将普通表单发布与普通AJAX混合在一起。下面是我希望实现的流程图