Reputation: 299
I am working in ASP.Net MVC. I am calling an Action Method from Javascript to redirect to another page. Following is my code.
$.ajax({
type: "POST",
datatype: "JSON",
url: "@Url.Action("UserExists","Default")",
data: {Email:$("#Email").val(),Password:$("#Password").val()},
success: function (data)
{
if (data == "yes") {
window.location="Home/Index" + $("#Email").val();// I wnat to send $("#Email).val() to Index method in Home controller.
}
else {
alert("Wrong");
}
}
});
Request and response is fine i.e. ajax calls. But not redirecting to other page, i.e. Home/Index/MyParameter . Please help me how to fix this problem.
Upvotes: 0
Views: 5481
Reputation: 1412
window.location.href = "/GridOrderSummary/GridRowSummary?ticketId=" +
ticketId;
//Controller code
public class GridOrderSummaryController : Controller
{
// GET: GridOrderSummary
public ActionResult GridRowSummary(string ticketId)
{
// your code
return View();
}
}
Upvotes: 0
Reputation: 3178
Try this (i have put in an extra '/' after Index:
window.location="Home/Index/" + $("#Email").val();
Or this (where email is the name of your action parameter in Index):
window.location="Home/Index?email=" + $("#Email").val();
Upvotes: 1