On-screen message with ajax and jquery

Asked

Viewed 70 times

-1

I have an approval system and need to display a message to the user every time they click the Approve button. How can I do it ? My code is that way:

Controller:

[HttpPost]
    public PartialViewResult AprovarPassagem(int[] idsCredito, int mes, int ano)
    {
        VendaModel model = new VendaModel();
        PeriodoService periodoservice = new Application.Service.PeriodoService();

        Venda lista = null;

        if (idsCredito != null)
        {
            DateTime dd = DateTime.Now;
            int dia = dd.Day;

            foreach (int pass in idsCredito)
            {
                 lista = vendaService.ListarPorId(pass);
                //if (lista.Acao != true && lista.Acao != false)
                //{
                    lista.Aprovada = true;
                    vendaService.Salvar(lista);
                //}
            }

        }

        model.ListaPeriodo = periodoservice.ListarTodos().Where(p => p.Id == mes && p.Ano == ano);

        foreach (var item in model.ListaPeriodo)
        {
            model.Venda = item.Vendas;
        }

        return PartialView("_ListaVendas", model);
    }

Jquery:

function Aprovar() {
$.ajax({
    url: 'Venda/AprovarPassagem',
    type: 'POST',
    contentType: "application/json; charset=utf-8",
    data: JSON.stringify({ idsCredito: RecuperarSelecionados(), mes: $("#ListaPeriodo").val(), ano: $("#ListaAno").val() }),
    success: function (data) {
        $("#listaParticipante").html(data);
    },
    beforeSend: function () {
        $.blockUI({ message: '<img src="' + url + '/Content/ajax-loader.gif" alt="Aguardando..."/>' });
    },
    complete: function () {
        $.unblockUI();
    },
    error: function (xhr, ajaxOptions, thrownError) {
        $("#error-message").append('Ocorreu um erro ao processar solicitação.');
        $('#message-red').show('blind');
    }
});

}

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.