After much research without results I come here to question you. The project is in MVC 5
using C#
.
This is the code that calls an MVC controller
$('#btnPesquisa').click(function () {
var textAPesquisar = $("#txtTermoDePesquisa").val();
$.ajax({
url: "/Pensamento/Pesquisar",
type: 'POST',
contentType: "application/json; charset=utf-8",
data: '{termoAPesquisar:' + JSON.stringify(textAPesquisar) + '}',
async: false
});
});
When I debug I see that the controller receives the value and even redirects me to Home
Index
and in this controller everything happens as it should, however in the browser the page does not change, everything stays the same.
[HttpPost]
public ActionResult Pesquisar(string termoAPesquisar)
{
return RedirectToAction("Index", "Home", new {query = termoAPesquisar });
}
If I call Home
Index
manually, through the browser address bar, everything happens as it should.
How can the code be executed and nothing happen?