使用XMLHttpRequest发送FormData数据到服务器
var xhr = new XMLHttpRequest();\n\nxhr.open('POST', 'handler.php', true);\n\nxhr.onload = function () {\n if (xhr.status !== 200) {\n console.log('An error occurred!');\n }\n};\n\nxhr.send(formData);\n这里formdata是什么数据内容:formData是一个可以用于发送和接收表单数据的对象。它可以包含表单中的键值对数据,并以键值对的形式进行访问和操作。在这段代码中,xhr.send(formData)将会发送formData对象中的数据到服务器的handler.php文件中。
原文地址: https://www.cveoy.top/t/topic/pp5O 著作权归作者所有。请勿转载和采集!