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

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‘});
});

 

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