Advertisement
corzopabloariel

Envio

Jul 17th, 2020
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. enviar = ( t ) => {
  2.     let url = t.action;
  3.     let method = t.method;
  4.     let idForm = t.id;
  5.     let formElement = document.getElementById(idForm);
  6.     let formData = new FormData( formElement );
  7.     grecaptcha.ready(function() {
  8.         $( ".form-control" ).prop( "readonly" , true );
  9.         Toast.fire({
  10.             icon: 'warning',
  11.             title: 'Espere, enviando'
  12.         });
  13.         grecaptcha.execute(public_key, {action: 'contact'}).then( function( token ) {
  14.             formData.append("token", token);
  15.             axios({
  16.                 method: method,
  17.                 url: url,
  18.                 data: formData,
  19.                 responseType: 'json',
  20.                 config: { headers: {'Content-Type': 'multipart/form-data' }}
  21.             })
  22.             .then(res => {
  23.                 if (parseInt(res.data.estado)) {
  24.                 } else {}
  25.             })
  26.             .catch(err => {})
  27.             .then(() => {});
  28.         });
  29.     });
  30. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement