weixin_33709219 2018-08-25 21:21 采纳率: 0%
浏览 23

NODE检索表单变量

I am French and no one in English so everything is translated by google! I am a beginner on NODE.

In my index.html file, there is a form that I send to the server via $ .ajax with the POST method

To retrieve this form on the server

app.post('/connexion', function (req, res) {
 
    var postData = '';
    var pathname = url.parse(req.url).pathname;
        console.log('Reçue: '+ pathname +' .');
        req.setEncoding('utf8');
        req.addListener('data', function(postDataChunk) {
            postData += postDataChunk;
            console.log('POST reçu ' + postDataChunk +'.');
        });

and on the console, I receive this in return

Reçue: /connexion .
POST reçu -----------------------------4511735334446617171533446239
Content-Disposition: form-data; name="pseudo"
 
Nath
-----------------------------4511735334446617171533446239
Content-Disposition: form-data; name="mdp"
 
moi
-----------------------------4511735334446617171533446239--
.
It's already good, I see that the form is sent!

But I do not find how to retrieve the values of the variables pseudo and mdp.

Can you help me understand and recover these values?

Thank you for your help

</div>
  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 Qt Vs2017使用Charts异常
      • ¥15 将位图选入内存DC失败,但没有出错信息
      • ¥20 如何从 .html url 启动/激活 .py 文件(sql debug)
      • ¥15 c#调用soap出错,soapui中可以
      • ¥100 CBIS-DDSM kaggle 资料处理
      • ¥30 python 在 excel 用 OpenPyXL 怎么实现以下代码
      • ¥15 pywinauto 无法捕获到元素
      • ¥15 ARfoundation (可能由于没打开摄像头的)黑屏问题
      • ¥15 pycharm打包项目包含mp3文件,运行exe程序后mp3文件没有执行。
      • ¥15 Quantlib求discount factors