I want to go to another page when I click on a button, but when I click, nothing happen & I'm stuck on the initial page + I have this error :
POST http://localhost:55703/Home/ValidStep1 404 (Not Found)
here's my code :
HomeController.cs
[HttpPost]
public JsonResult ValidStep1(Dictionary<string, List<string>> listUsers){
//some code
}
Index.cshtml
jQuery.post('/Home/ValidStep1', { listUsers: listUser }, function (data) {
if (data) {
document.location.replace("@ViewBag.nextStep");
}
else {
document.location.replace("@ViewBag.errorStep");
}
});
Do you have any idea ?
Ok, now it works with this following code. BUT I DON'T KNOW WHY. It's like... the same as above.
jQuery.ajax({
type: 'POST',
url: '@Url.Action("ValidStep1", "Home")',
data: { listUsers: listUser },
success: function (data) {
document.location.replace("@ViewBag.nextStep");
},
error: function () {
document.location.replace("@ViewBag.errorStep");
}
});