drymoeuka282427675 2014-11-17 09:13
浏览 29

Node.js数据传输

I am transferring data from node to PHP. I am using same url to transfer data and may require to call it for more than 10 times in a loop, but it only accepts 5 times. The next 5 will be error (parse error). How to fix it?

code

function win_settings_fn(noos)
    {


                     var str="";
                     var len = str.length ;
                     win_settings.headers = {'Content-length' : len, 'Content-Type': 'application/x-www-form-urlencoded'}     

                     var request = http.request(win_settings, function (response) {
                     response.on('data', function (data) {


                        var response= JSON.parse(data);

                        console.log(str+"respose   ..........."+noos);


                     });

                     response.on('error', function (err) {

                     });

                     response.on('end', function () {

                                       });
                       });


                     request.on('error', function (err) {

                        console.log("failed.............."+noos);

                     });
                     request.write(str +"\0");
                     request.end();

              }

This is the code am using.

if I call

win_settings_fn(1)
win_settings_fn(2)
win_settings_fn(3)
win_settings_fn(4)
win_settings_fn(5)
win_settings_fn(6)
win_settings_fn(7)
win_settings_fn(8)
win_settings_fn(9)
win_settings_fn(10)

The result is

respose   ...........1
respose   ...........2
respose   ...........3
respose   ...........4
respose   ...........5
failed..............6
failed..............7
failed..............8
failed..............9
respose   ...........10

Why is it so? Is there any issue with sending the data?

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算