Redirect express route when accepting ajax post requests?

  node.js, question

Well, I want the front-end page to process some data in the background through ajax post, and the results are redirected all the time.

The front page code is as follows:

function sendVerticyCode (){
 
 var phoneNumber = $('[name=username]').val().trim();
 console.log(phoneNumber)
 
 if(Number(phoneNumber) !  == NaN){
 $.ajax({
 type: "POST",
 url: "/sendcode",
 data: Number(phoneNumber),
 success: function(msg){
 Alert( "phone number is "plus msg);
 bracket
 });
 bracket
 
 bracket

The background processing page is as follows:

router.route('/sendcode')
 .post(function (req, res, next) {
 /*
 accept the phonenumber then send verticy code
 */
 console.log(req.body.data)
 var  phoneNumber  = req.body.data ;
 console.log(phoneNumber)
 
 messageXSend.add_to(phoneNumber);    // must be string ?  ?  ?
 realcode = crevertiCode();
 console.log(realcode)
 messageXSend.add_var('code',realcode);
 Messagexsend.add _ var ('time',' 60 seconds');
 messageXSend.set_project('fwgU');
 messageXSend.xsend();
 
 
 })
 
 
 
 
 The route matching is correct. There should be a problem with the back-end processing code, but no error was reported.

In this way,
First, debug the back-end code to see if it has been executed.
Second, which page did you say the page jumped to? Try to arrange the code to see if there is any route to other hops.
Third, post the code that triggers sendVerticyCode () on your page