Avatar ·

How to handle redirect after AJAX request in jQuery?

Hello everyone! I'm a beginner in web development and I've been stuck on a problem for two days now. I have a login form on my site. When the user enters data, I send it to the server via AJAX using jQuery. If the login is successful, the server should redirect the user to the main page (redirect to `/dashboard`). But instead, nothing happens — the page doesn't reload, and the user stays on the login page. Here's my code: ```javascript $.ajax({ url: '/api/login', type: 'POST', data: { username: 'user', password: 'pass' }, success: function(response) { console.log('Success:', response); // Here I expect the browser to follow the redirect automatically } }); ``` The server (Node.js) returns this response: