ID不是从nodejs中的链接保存的

时间:2019-10-06 07:27:01

标签: javascript jquery node.js express node-modules

我想将反馈页面中的票证ID保存到数据库中,该怎么办?

问题在于此行“ const ticketId ='ticketId';” 、、、、、、、、、、、、、、、、、、、、、、、、、 、、、、、、、、、、、、、、、、、、、、、、、、

js代码:

   const ticketId = 'ticketId';
    let rating =[];
    $(".starrr").each((index)=>{
        rating.push({
                    _id:$(`.star-c-${index}`).attr("id"),
                    value:parseInt($(`.star-c-${index}`).attr("data-rating"))
                })
    });

    const comment = $("#comment-feedback").val();
    const feedbackObj = {
        comment:comment,
        rating:rating
    }

控制器:

  const feedbackform = async (req, res) => {

  Rating.find({delete: false, school : req.session.currentSchool._id}).exec(function(err, ratings){
    if(err)
    {
      console.log(err)
    }
    else
    {
      console.log(ratings);



      req.flash('success', 'Successfully saved feedback');
      res.render("ticket_feedback",{ratingDetail:ratings, ticketId:req.params.id})
    }
  })

};

  router.get('/feedbackform/:id', feedbackform);

链接:

<a href="http://localhost:3000/ticket/feedbackform/59b02734e3008a5a6ebcef50" class="btn btn-primary"> Feedback </a>

0 个答案:

没有答案