Jquery 无法重定向页面nodeJS/mongo

Jquery 无法重定向页面nodeJS/mongo,jquery,node.js,mongodb,mongoose,pug,Jquery,Node.js,Mongodb,Mongoose,Pug,我有一篇基于按钮的ajax帖子,表单有自己的帖子。每次单击按钮时,都会生成一个post,但它不会重定向到userProfile页面,即使它调用get并返回304 以下是脚本文件: $('.removeEmail').click(function() { $.post('/removeEmailPost', {userE: $(this).data('user')}); }); 以下是路由文件: exports.newEmailPost = functio

我有一篇基于按钮的ajax帖子,表单有自己的帖子。每次单击按钮时,都会生成一个post,但它不会重定向到userProfile页面,即使它调用get并返回304

以下是脚本文件:

 $('.removeEmail').click(function() {
        $.post('/removeEmailPost', {userE: $(this).data('user')});
        });   
以下是路由文件:

exports.newEmailPost = function(req, res) {
    if(req.body.emailNew === '') {
        console.log('blank');
        res.redirect('editUserProfile');
    } else {
        User.findByIdAndUpdate(req.signedCookies.userid,{
            $addToSet: {emailList: req.body.emailNew}
        }, function(err, userX) {
            if(err) {
                console.log(err);

            } else {

                res.redirect('userProfile');
            }       
            console.log(userX);
        });     
    }

};

type=“button”
属性添加到您的
,这样它在单击时不会自动提交表单。

嘿,对不起,是的,我这样做了,但现在我遇到了另一个问题。。。我把问题调高了,有什么线索吗?你不应该改变你的问题。。如果需要,撤消更改并提出新问题