几天以来,我试图解决这个问题。需要什么:1)将数据从 JSON(异步获取等待)发布到 php 2)接收数据并将其上传到我的服务器实际上,从现在开始,我从我的 PHP 收到了一个答案,但是这个在我的 console.log 中是空的。请看下面的代码:从 FORM JSON 发送数据;使用异步获取等待 PHP MySQL感谢您的帮助,和往常一样,我继续寻找答案。这个会发帖。表格  <form id="form">    <div id="areachatbox"></div>    <textarea type="text" id="message" name="message" ></textarea>    <input id="submit" type="submit" value="Send">  </form>JSON:        <script>const form = document.getElementById('form'); form.addEventListener('click', textarea);     async function textarea(event) {      event.preventDefault();      const msg = document.getElementById('message').value;      const response = await fetch('chatpost.php', {        method: 'post',        body:JSON.stringify({msg})      })      const data = await response.text();      console.log(data);    }    </script>和PHP<?php $json = json_decode(file_get_contents('http://localhost/XXXXXX/homepage.php'), true);echo $json['msg'];?> 
                    
                    
                - 1 回答
- 0 关注
- 127 浏览
添加回答
举报
0/150
	提交
		取消
	
