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:
question from:
https://stackoverflow.com/questions/65872099/browser-showing-loading-even-after-executing-con-query 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…