0
After much research without results I come here to ask you. The project is in MVC 5
using C#
.
This is the code that calls a 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 the Home
Index
and in this controller everything happens as it should, however in the browser the page does not change, everything is the same.
[HttpPost]
public ActionResult Pesquisar(string termoAPesquisar)
{
return RedirectToAction("Index", "Home", new {query = termoAPesquisar });
}
If I call the Home
Index
manually, through the browser’s address bar, everything happens as it should.
How is it possible for code to be executed and nothing happens?
Missed the return of
$.ajax
! and also the method is wrong ... should return a json to screen! Although now I was in doubt what is your main purpose?– novic