Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
118 views
in Technique[技术] by (71.8m points)

javascript - browser showing loading even after executing con.query

I have the code below:

app.post('/add', function(req,res){

  let addcar = req.body.car;
  let addnumber = req.body.number;

  var ssql = "SELECT 1 from cardata where email = '" + addcar + "' or number = '" + addnumber + "'";

  con.query(ssql, function (err, result, fields) {
    
    if(result[0]){
      console.log("Number or Email Already Exists!")
    }
    else{
      var sql = "INSERT INTO cardata (car, number) VALUES ('" + addcar + "' , '" + addnumber + "')";
      con.query(sql, function (err, result) {
        if (err) throw err;
        console.log("1 record inserted");
      });
    }
  });
});

Whenever I run node server.js, the code works fine and does what it is supposed to. However, the browser shows that the page is still loading even after the record has been inserted into the db. Is there anyway I can end the program to make it stop loading?

Here's a screenshot of what it looks like: ScreenshotLoading Bar

question from:https://stackoverflow.com/questions/65872099/browser-showing-loading-even-after-executing-con-query

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...