Skip to content

Commit

Permalink
test request
Browse files Browse the repository at this point in the history
  • Loading branch information
CYH1426 committed Nov 11, 2023
1 parent 5c57e76 commit f40ea81
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/join/Markdown editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,21 @@
// 创建一个 FormData 对象,用于上传文件
var formData = new FormData();
formData.append("markdownFile", blob, "document.md");

var dataToSend = "Hello, Server!";
// 发送 POST 请求将文件上传到后端
var xhr = new XMLHttpRequest();
xhr.open("POST", "api.anxiu.cloud/contribute", true);
xhr.open("POST", "http://localhost:8080/receiver//GetMdServlet", true);
xhr.setRequestHeader("Content-Type", "text/plain");
xhr.onload = function() {
if (xhr.status === 200) {
// 上传成功,可以在这里处理后端返回的响应
console.log("File uploaded successfully!");
console.log("Response received:", xhr.responseText);
} else {
// 上传失败
console.error("File upload failed");
}
};
xhr.send(formData);
xhr.send(dataToSend);
});
});
</script>
Expand Down

0 comments on commit f40ea81

Please sign in to comment.