会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 134107个问题

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>post请求</title>
</head>
<body>
  <label for="username">
      <span>用户名:</span>
      <input type="text" id="username" class="username">
  </label> <br>
  <label for="password">
      <span>密码:</span>
      <input type="text" id="password" class="password">
  </label> <br>
  <button>登录</button>
<script>
      var usernameInput=document.querySelector('.username');
      var passwordInput=document.querySelector('.password');
      var btn=document.querySelector('button');
      btn.onclick=function () {
          var xhr=new XMLHttpRequest();
          xhr.onreadystatechange=function () {
              if(xhr.readyState==4){
                  if (xhr.status==200){
                    // console.log(xhr.responseText);
                    console.log(JSON.parse(xhr.responseText));
                  }
              }
          };
          xhr.open('post','3-post请求.php',true);
         //构建post表单数据,使用FormData类构建数据
          var datas=new FormData();
          datas.append('uname',usernameInput.value);
          datas.append('upass',passwordInput.value);
          xhr.send(datas);
      }
</script>
</body>
</html>
<php
 $success=array("msg"=>"ok","info"=>$_POST);
 echo json_encode($success);
?>

老师我这个里面报错了,我不知道是哪的问题

blob.png

WEB前端全系列/第六阶段:Http服务与Ajax模块(旧)/Http服务与Ajax编程 12286楼

旅行.7z


老师,这个

springboot怎么启动不了是为啥照着视频也还是不行



JAVA 全系列/第十一阶段:百战旅游网项目/百战旅游网 12287楼
JAVA 全系列/第一阶段:AI驱动的JAVA编程/IDEA的使用和第一个java项目 12288楼
Python全系列/第二阶段:Python 深入与提高/模块 12291楼
Python全系列/第六阶段:数据库与AI协同技术实战/mysql的使用 12292楼
JAVA 全系列/第九阶段:SpringBoot与MybatisPlus/Spring Boot旧 12293楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/智能电话本项目实战 12294楼
Python全系列/第二阶段:Python 深入与提高/文件处理 12295楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637