Ajax的后期不会渲染/发送页面,节点和expression

所以我试图让ajax发送一个请求到服务器来呈现一个新的页面。

$('#statistics').click(function () { $.ajax({url:'profile', type:'POST', success:function(){console.log("Success!"); }}); }); 

然后到达。

profile.js

 router.post('/',function(req,res,next){ res.redirect('statistics'); }); 

谁反过来达到。

statistics.js

 router.get('/', function(req, res, next) { res.send("wat up"); }); 

我没有从我所能看到的错误中得到任何错误,并且我确信它传递了我在这里给出的所有代码,因为当我在profile.js的后面放置了一堆console.log并获取了statistics.js他们都打印。 然而,当我点击p元素似乎没有发生。 浏览器卡在同一页面。

编辑:

App.js

 var express = require('express'); var helmet = require('helmet'); var csrf = require('csurf'); var path = require('path'); var favicon = require('serve-favicon'); var flash = require('connect-flash'); var logger = require('morgan'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var session = require('express-session'); var routes = require('./routes/index'); var users = require('./routes/users'); var profile = require('./routes/profile'); var statistics = require('./routes/statistics'); var app = express(); // view engine setup app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs'); // uncomment after placing your favicon in /public //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); app.use(logger('dev')); //Security shyts app.use(helmet()); app.use(helmet.xssFilter({ setOnOldIE: true })); app.use(helmet.frameguard('deny')); app.use(helmet.hsts({maxAge: 7776000000, includeSubdomains: true})); app.use(helmet.hidePoweredBy()); app.use(helmet.ieNoOpen()); app.use(helmet.noSniff()); app.use(helmet.noCache()); // rest of USE app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); app.use(cookieParser()); app.use(session({secret: 'anystringoftext', saveUninitialized: true, resave: true, httpOnly: true, secure: true})); app.use(csrf()); // Security, has to be after cookie and session. app.use(flash()); app.use(express.static(path.join(__dirname, 'public'))); // csrfToken usage app.use(function (req, res, next) { var token = req.csrfToken(); res.locals.csrfToken = token; next(); }); app.use('/', routes); app.use('/users', users); app.use('/profile', profile); app.use('/statistics', statistics); // catch 404 and forward to error handler //app.use(function(req, res, next) { // var err = new Error('Not Found'); // err.status = 404; // next(err); //}); // error handlers // development error handler // will print stacktrace if (app.get('env') === 'development') { app.use(function(err, req, res, next) { res.status(err.status || 500); res.render('error', { message: err.message, error: err }); }); } // production error handler // no stacktraces leaked to user app.use(function(err, req, res, next) { res.status(err.status || 500); res.render('error', { message: err.message, error: {} }); }); module.exports = app; 

       

网上收集的解决方案 "Ajax的后期不会渲染/发送页面,节点和expression"