window.location.href is not working for me :/ everthin is running on a localhost with "xampp"
//javascript function 1
function onLogin() {
window.location = "http://localhost:4000/deletetable";
console.log("running...");
console.log(window.location.href);
return false;
}
// !node.js! function 2 in other file(server.js)
//Delete Table
app.get('/deletetable', (req, res) =>{
let sql = 'DROP TABLE IF EXISTS users';
db.query(sql, (err, result) => {
if(err) throw err;
console.log(result);
});
});
//html...
<form onsubmit="onLogin();">
<div class="wrapper">
<button class="downloaded-btn"></button>
</div>
</form>
//only a button...
I tried everthing in the url window.location.href = "url"
but nothing works. Thanks for help!