Requirement is to redirect from 'index.html' to 'userdetails.html' page on click of button (type = button)
I have 3 forms in index.html (each form to serve different purpose)
All have method=Post.
In the second form, I have a button with type=button and id=userdetails, and onclick="sendDetails()"
Now function on same page:
function sendDetails(){
$.ajax({
method: "GET",
url: "/newColl",
success: function(data) {
$('#form2').attr('action', '/userdetails');
}
Now I have index.js page which has following function:
var createGroup = function(//<manipulation on mongodb>)
router.get('newColl', function(req, res, next){
// mongo connection and calling createGroup function
// this is working fine.
client.close()
});
router.post('/userdetails', function(req, res, next) {
res.redirect('userdetails.html');
}
I tried with res.redirect, res.sendFile, res.render, window.location.href(in html), but all in vain.
Please can anybody guide.
Thanks