JavaScript XMLHttpRequest: 发送数据到服务器
var xhr = new XMLHttpRequest();\nxhr.open('POST', 'handler.php', true);\nxhr.onload = function () {\n if (xhr.status !== 200) {\n console.log('An error occurred!');\n }\n};\nxhr.send(formData);\n最后是 xhr.send(formData) 因为它负责将请求发送到服务器。xhr.send() 方法用于向服务器发送请求,并可以将数据作为参数传递给服务器。在这个例子中,formData 就是要发送给服务器的数据。
原文地址: https://www.cveoy.top/t/topic/pp5M 著作权归作者所有。请勿转载和采集!