im using MVC3. im trying to redirectToAction after doing a jquery post.
edit: sorry for not being specific. Whenever it reaches the return RedirectToAction, it just refreshes the same page and returns to the same current view.
my View code is as follows:
$("button[name='command']").click(function () {
var checked_status = null;
if ($("#select_all").is(':checked')) {
checked_status = true;
} else {
checked_status = false;
}
$.post('@Url.Action("SaveInvitations", "Contractors")',
{
command: $(this).val(),
selectedContractors: $("input[name='selectedContractors']:checked").map(function () { return $(this).val(); }).get().join(","),
page: $(".selected").text(),
CheckedAll: checked_status
});
});
and my controller has the following:
if (command == "skip")
{
TempData["message"] = string.Format("No contractors where selected");
RedirectToAction("Index", "Home");
}
else
{
...
TempData["message"] = string.Format("The invitations have been send successfully.");
Session["subModel"] = null;
return RedirectToAction("Index", "Home");
}
Then again, im just trying to do a redirectToAction after a jquery $.post. What do I have to do to make it work?