问题描述
最近,我一直在尝试制作一个网站,将数据发送到运行它的 node.js 程序,但最近我在我的 localhost 网站上的 html 中制作了一个提示框,并尝试从该提示中接收数据通过 http 扩展程序框到我的 node.js 应用程序中,我将如何处理?
function buy() {
const xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST","/buyITEM",true);
const PromptW = window.prompt("Enter ID of the item to buy:");
xmlhttp.send(PromptW);
}
这是我的 node.js 应用程序的一部分:
http.createServer(function(requestt,server) {
server.writeHead(200,{'Content-Type': 'text/html'});
server.end(htmlFile);
var pathname = url.parse(requestt.url).pathname;
switch(pathname){
case '/buyITEM':
const body = requestt.body.value;
console.log(body)
break;
}
}).listen(80);
感谢所有帮助
(这是我的第一篇文章,如果它很糟糕,请见谅。)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)