0

Antes de cualquier cosa cabe aclarar que soy nueva programando. Tengo un swal en el cual se puede pulsar aprobar o rechazar, hasta ahí normal, ya tengo el ajax que me hace esto, pero ahora necesito que cuando le pinchen en rechazar me dé la opción de agregar comentarios sobre ese rechazo, pensé en hacer un swal dentro de ese que ya tengo, pero realmente no sé como hacerlo, o que me pueden recomendar.

Aquí les dejo el código:

swal({ title: "¿Qué deseas hacer con esta Solicitud?", text: "", type: "warning", showCancelButton: true, confirmButtonColor: '#DD6B55', confirmButtonText: 'Aprobarla', cancelButtonText: "Rechazarla", closeOnConfirm: false, closeOnCancel: false, }, function (isConfirm) { if (isConfirm) { var aprobado = 2; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "Default.aspx/Aprobar", data: "{IdSolicitud:'" + IdSolicitud + "', IdEstado:'" + aprobado + "', IdAprueba:'" + idAprueba + "'}", dataType: "json", success: function (data) {
debugger; CargarTablaPendientes(); CargarTablaHistorico(); swal("¡Excelente!", "La solicitud se ha aprobado.", "success"); }, error: function (result) {

                    alert("Se ha producido un error al cargar al aprobar la solicitud, contacte al administrador.");
                }
            });
        } else {
            var rechazado = 3;
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "Default.aspx/Aprobar",
                data: "{IdSolicitud:'" + IdSolicitud + "', IdEstado:'" + rechazado + "', IdAprueba:'" + idAprueba + "'}",
                dataType: "json",
                success: function (data) {
                    CargarTablaPendientes();
                    CargarTablaHistorico();
                    swal("¡Excelente!", "La solicitud se ha rechazado.", "success");
                },
                error: function (result) {
                  //  debugger;
                    alert("Se ha producido un error al cargar al rechazar la solicitud, contacte al administrador.");
                }
            });
        }

    });

}

De antemano muchas gracias por leerme

1 respuesta 1

0

Hola echa un vistazo a la página oficial en la sección de ejemplos puedes ver algo con AJAX:

Swal.fire({
  title: 'Submit your Github username',
  input: 'text',
  inputAttributes: {
    autocapitalize: 'off'
  },
  showCancelButton: true,
  confirmButtonText: 'Look up',
  showLoaderOnConfirm: true,
  preConfirm: (login) => {
    return fetch(`//api.github.com/users/${login}`)
      .then(response => {
        if (!response.ok) {
          throw new Error(response.statusText)
        }
        return response.json()
      })
      .catch(error => {
        Swal.showValidationMessage(
          `Request failed: ${error}`
        )
      })
  },
  allowOutsideClick: () => !Swal.isLoading()
}).then((result) => {
  if (result.value) {
    Swal.fire({
      title: `${result.value.login}'s avatar`,
      imageUrl: result.value.avatar_url
    })
  }
})

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.