node.js - nodejs前端频繁post 导致很卡的问题
阿神
阿神 2017-04-17 15:22:21
0
1
543

前端js,post过去,频繁的点击,就很卡。
这是nodejs的代码:

    var express = require('express');
    var bodyParser = require("body-parser");
    var app = express();

    app.use(express.static('app'));
    app.use(bodyParser.urlencoded({ extended: false }));

    var server = app.listen(config.socket_port, function () {

      var host = server.address().address
      var port = server.address().port

      console.log("应用实例,访问地址为 http://%s:%s", host, port)

    })

    var post_callback = function (post_res, err, res){
        return post_res.end(JSON.stringify({err:err, res:res}));
    }

    app.post('/post', function(req, post_res) {

        let data = req.body;
        let filter = JSON.parse(data.filter);

        return post_callback(post_res, null, []);
    });

这是前端的代码,jquery

$.post(configObj.socket_url+'post', {dbname: _this.dbname, action:_this.dbname+'__get', filter:JSON.stringify(filter)},function(res){
            let jsonObj = JSON.parse(res);
            console.log(jsonObj);
            callBack(jsonObj.err, jsonObj.res);
        });

仔细分析,我没发现哪里出现性能问题。我只是用鼠标快速的点几十下而已。页面就卡了。电脑都非常的卡。

阿神
阿神

闭关修行中......

reply all(1)
迷茫

The page lag has nothing to do with the server. In addition, similar application scenarios in actual applications will limit requests to avoid continuous invalid clicks

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template