I want to redirect the user from a page's script in order to pass it some variables. However when I try to redirect the user, I just receive the HTML as an alert.
Script
$.post("http://localhost:4000/testPost",
{
array: valueArray
},
function (data, status) {
alert("Data: " + data + "\nStatus: " + status);
});
Server.js
app.get('/test', function (req, res) {
return res.render('pages/test',{
array : req.array
})
});
app.post('/testPost', function (req, res) {
console.log(res)
return res.redirect('/test')
});
HTML (test.ejs)
<!DOCTYPE html>
<html>
<p>Hello</p>
</html>