express 4.x req.query(get方式) req.body(post方式) 接收浏览器发送过来的数据

var _id = '123456';
$.post('/user/delete', {id: _id}, function(data){
    if (data.error){
       $('#removeTips').html('删除异常:' + data.error + '  请刷新重试。');
    }else{
       window.location.href = '/admin/';
    }
 }, 'json');

var express = require('express');
var router = express.Router();
router.route('/user/delete').post(function(req, res){
    var _id = req.body.id;
    console.log(_id); // 123456
    res.json({result: 'success'});
});

 

转载于:https://www.cnblogs.com/yexiangwang/p/5978018.html

你可能感兴趣的:(后端,json)