4
I have this Script:
$('#Musico').change(function () {
var id = $(Musico).val();
var url = '@Url.Action("Votar","Chamada")';
var tipo = 1;
$(function ChamaVotar() {
$.post(url, { id: id, tipo: tipo });
});//Function ChamaVotar
});//musico change
And this controller:
public ActionResult Votar(int id, int tipo)
{
if (tipo == 1)//Tipo Musico
{
var chamadaMusicas = db.ChamadaMusicas.Include(c => c.Chamada).Include(c => c.Musica).Where(c => c.Chamada.PessoaID.Equals(id)).Where(i => i.Chamada.Ativa.Equals(true)).ToList();
return View(chamadaMusicas);
}
else//Local
{
var chamadaMusicas = db.ChamadaMusicas.Include(c => c.Chamada).Include(c => c.Musica).Where(c => c.Chamada.LocalID.Equals(id)).Where(i => i.Chamada.Ativa.Equals(true)).ToList();
return View(chamadaMusicas);
}
}
I need, when passing my parameters to the controller, to open the view. But it is not opening... The controller receives the information but does not open the page. What solution for this?
I do not know if it is the most appropriate way to do this, should put a form in the view that takes the parameters and give a Ubmit, this way you are only giving the post, there is no instruction in your javascript to redirect to the view returned by the controller.
– FBatista