前端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);
});
仔细分析,我没发现哪里出现性能问题。我只是用鼠标快速的点几十下而已。页面就卡了。电脑都非常的卡。
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