Express failed to submit the form using ajax. App.post is invalid.

Code

// ajax
$.ajax({
  url: "/process",
  type: "POST",
  data: $(this).serialize(),
  success: function(data) {
    if (data.success) {
      $container.html("<h2>Thank you!</h2>");
    } else {
      $container.html("There was a problem.");
    }
  },
  error: function() {
    $container.html("There was a problem");
  }
});
// app.jsapp.post
app.post("/process", function(req, res){
    if(req.xhr || req.accepts("json,html")==="json"){
        res.send({ success: true });
    } else {
        res.redirect(303, "/thankyou");
    }
});

however, the result is: There was an arguments!
Open FF, and show

clipboard.png
obviously used app.post for request processing, what went wrong? How to solve?

Mar.16,2021

mistakenly placed app.post after the app.use (req, res, next) middleware function, causing app.post to fail to process post requests. Solution: just put app.post in front of the middleware function. follow-up understanding: as long as you return 404, you should think of "what you asked for, you didn't give it to me". So generally speaking, it is the piece of code that processes the request that goes wrong.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e50ec6-436a3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e50ec6-436a3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?