How to make Ajaxpost request after Ajaxget completed

Asked

Viewed 17 times

-1

The problem is that when I call the post it does not return either in Success, error or complete. Some sicrona definition is missing?

this.funcget = function () {
        var paciente;
        $.ajaxGet(global.Router.action("Paciente", "BuscaPaciente", { pacienteId: $(this).val('button').attr('PacienteId') }),
        {
            success: function (info) {
                paciente = info;
            },
            complete: function () {
    // aqui eu chamo o AJaxPost
                me.NovoPaciente(paciente);
            },
            error: function () {
                alertify.error("Não foi possivel salvar os dados do paciente.");
            },
        }
        );
    };

    this.NovoPaciente = function (paciente) {
        if (paciente.planoId > 0) {
            window.open(global.Router.action("Paciente", "Formulario", { planoId: paciente.planoId }));
        }
        else {
            var paciente;
    //chamada do post
            $.ajaxPost(global.Router.action("Paciente", "NovoPaciente", { PacienteId: paciente.pacienteExternoId })),
              {
                  success: function (infoP) {
                      paciente = infoP;
                  },
                  error: function () {
                      alertify.error("Não foi possivel salvar os dados do paciente.");
                  },
                  complete: function () {
                      if (!paciente.erro)
                          window.open(global.Router.action("Paciente", "Formulario", { planoId: paciente.planoId }));
                      else
                          alertify.error(paciente.msgErro);
                  },
              };
        }

    }

1 answer

0


I found out. in the request ajaxpost I was closing a parentheses before the key with that closed the ajax block.

Browser other questions tagged

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