Hi AliYilmaz,
Once a form is submitted, you are no longer on that page.
You have navigated to the specified url.
So you can implement this by submitting the first action using jQuery AJAX and then submit the form to the second action.
Check the below example.
Controller
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
return View();
}
public JsonResult AjaxMethod(string name)
{
return Json(name);
}
}
View
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<form>
<table>
<tr>
<td>Name</td>
<td><input type="text" id="txtName" /></td>
</tr>
<tr>
<td></td>
<td><input type="button" id="btnRegister" value="Register" /></td>
</tr>
</table>
</form>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$("#btnRegister").click(function () {
$.ajax({
type: "POST",
url: "/Home/AjaxMethod",
data: "{ name:'" + $("#txtName").val() + "' }",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert("Hello: " + response);
window.location.href = "https://www.aspsnippets.com/";
},
failure: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
});
});
});
</script>
</body>
</html>
Screenshot