Why does the following not work?
res.send({ successMessage: 'Task saved successfully.' }); res.redirect('/');
I basically need the successMessage command for AJAX requests. Forwarding is required when the request is a standard mail request (not AJAX).
The following approach does not seem to me very clean, since I do not want to care about the interface technology in my backend:
if(req.xhr) { res.contentType('json'); res.send({ successMessage: 'Aufgabe erfolgreich gespeichert.' }); } else { res.redirect('/'); }
mosquito87
source share