Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

333
Views
TypeError no capturado: jQuery(...).submit(...) .then no es una función

Tengo un problema con mi código, capturando los datos de un formulario y luego enviándolos mediante un POST usando Fetch, sin embargo, tengo este error en la consola:

TypeError no detectado: jQuery (...). Enviar (...). Entonces no es una función

Algún desarrollador podría orientarme, se lo agradecería mucho

PD: No soy desarrollador, trabajo en marketing digital

 jQuery('form').submit(function() { var $form = jQuery(this); var email = $form.find("input[name='email']").val(); const userID = "id" + Math.random().toString(16).slice(2); var d = new Date(); var exdays = 365; d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); document.cookie = "Prodcuto" + "=" + email + "; " + expires + ";path=/"; dataLayer.push({ 'event': 'Lead', 'email': email, 'product': Producto ' }); localStorage.setItem('email', email); localStorage.setItem('userID', userID); localStorage.setItem('ip', ipUser); const data = new FormData(); data.append('email', email); data.append('user_id', userID); data.append('ip', ipUser); fetch('https://webhook.site/aeeaeaee', { method: 'POST', body: data }) }) .then(function(response) { if (response.ok) { return response.text() } else { throw "Error en la llamada Ajax"; } }) .then(function(texto) { console.log(texto); }) .catch(function(err) { console.log(err); });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Algo como esto debería funcionar:

 async function sendForm(){ return new Promise((resolve, reject) => { jQuery('form').submit(async function() { var $form = jQuery(this); var email = $form.find("input[name='email']").val(); const userID = "id" + Math.random().toString(16).slice(2); var d = new Date(); var exdays = 365; d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); document.cookie = "Prodcuto" + "=" + email + "; " + expires + ";path=/"; dataLayer.push({ 'event': 'Lead', 'email': email, 'product': 'Producto' }); localStorage.setItem('email', email); localStorage.setItem('userID', userID); localStorage.setItem('ip', ipUser); const data = new FormData(); data.append('email', email); data.append('user_id', userID); data.append('ip', ipUser); const response = await fetch('https://webhook.site/aeeaeaee', { method: 'POST', body: data }) resolve(response); }); }) } try { const response = await sendForm(); if (response.status >== 200 && response.status <== 299) { console.log('bueno'); } } catch(error) { console.log(error) }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!