简体   繁体   English

动作标签在实时服务器与代码中不起作用

[英]The action tag is not working in live server vs code

I am trying to run html file using the form in the vs code.我正在尝试使用 vs 代码中的表单运行 html 文件。 But the live server is not allowing it to run.但是实时服务器不允许它运行。 I tried it with normal chrome to run the file both files are running in normal chrome but not on the live server also it is navigation to welcome file when submit is clicked.我尝试使用普通 chrome 运行文件,这两个文件都在普通 chrome 中运行,但不在实时服务器上,当单击提交时,它导航到欢迎文件。 Don't know what's wrong with the vs code.不知道vs代码有什么问题。 Code below: welcome.html代码如下:welcome.html

<head>
    
</head>
<body>
    <h1>Welcome To The Prajakta's LOGIN</h1>
</body>
</html>
Validateform
<html>
<head>
   <script>
       function val()
       {
          
           var name=document.getElementById("txtname").value;
           var pass=document.getElementById("txtpass").value;
          /* if(name==null||name=="")
           {
               alert("Name cannot be blank")
               return false;
           }
           else if(pass.length<6)
           {
               alert("Minimum length of password should be more than 6");
               return false;
           }*/
       }
       </script>
</head>
<body>
    <form method="POST" action="welcome.html" onsubmit="val()">
        Name : <input type="text" id="txtname" name="txtname"><br>
        Password : <input type="password" id="txtpass" name="txtpass"><br>
        <input type="submit" value="Click here">
        </form>
</body>
</html>

I tried it with normal chrome to run file both files are running in normal chrome but not in live server.

When you are running on the live server, your form is sending a POST request to the /welcome.html file which is no handing that request that is why you are receiving 405 Method Not Allowed当您在实时服务器上运行时,您的表单正在向/welcome.html文件发送POST请求,该文件没有处理该请求,这就是您收到405 Method Not Allowed的原因

There should be something at the back that handles the POST method, called as server-side or back-end technologies.后面应该有一些东西来处理POST方法,称为服务器端或后端技术。 Each server-side language (PHP, Python, Ruby, Java, C#, etc.) has its own mechanism of handling form data. Each server-side language (PHP, Python, Ruby, Java, C#, etc.) has its own mechanism of handling form data.

Example welcome.php示例欢迎。php

<html>
<body>
  <h1>Welcome To The Prajakta's LOGIN</h1>
  Hi <?php echo $_POST["txtname"]; ?>
</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM