Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('#buy-submit').click(function(event) {
- // Stop the browser from submitting the form.
- event.preventDefault();
- var formData = $('#buyForm').serialize(),
- userName = document.getElementById('name'),
- userEmail = document.getElementById('email'),
- sendButton = document.getElementById('buy-submit'),
- r = document.getElementsByName('pago'),
- pago = -1,
- valor;
- for(var i=0; i < r.length; i++){
- if(r[i].checked) {
- pago = i;
- valor = r[i].value;
- }
- }
- console.log(formData);
- if (userName.value === '') {
- swal("Oops", "Debe indicarnos su nombre...", "error");
- console.log('Error en nombre');
- } else if (userEmail.value === '') {
- swal("Oops", "Debe indicarnos un correo de contacto...", "error");
- console.log('Error en email');
- } else if (pago == -1) {
- swal("Oops", "Debe seleccionar un ciclo de facturación", "error");
- } else {
- $.ajax({
- type: 'POST',
- url: $('#contactForm').attr('action'),
- data: formData,
- success: function(res) {
- swal({
- title: "¡Perfecto!",
- text: "Su mensaje se ha enviado correctamente haga click en continuar",
- type: "success",
- showCancelButton: false,
- confirmButtonText: "continuar"
- }, function() {
- // Redirect the user
- window.location.href = 'http://lab.abr4xas.org/viser/';
- });
- sendButton.disabled = true;
- console.log('¡¡HELL YEAH!!');
- console.log(res);
- },
- error: function(err) {
- swal("Oops", "Algo salió mal... Intente enviar su mensaje más tarde.", "error");
- console.log('WHAT THE F... ');
- sendButton.disabled = false;
- console.log(err);
- }
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement