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

94
Views
La página XHR sigue recargando después de la verificación de cookies

Este es mi código js, creo que tengo un bucle en la solicitud xhr ya que sigue cargando incluso sin la función de cookies; Estoy tratando de mostrar el "TnC" si no hay ninguna cookie. Sin embargo, continúa repitiendo la solicitud si es un no.

Además, cuando hago clic en aceptar en el formulario de envío, se vuelve a cargar.

muchas gracias por la ayuda

//función de cookies:

 function setCookie(cname, cvalue, exdays) { if(document.getElementById('agree').checked){ const d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); let expires = "expires="+d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } } function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i<ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1); if (c.indexOf(name) == 0) return c.substring(name.length,c.length); } return ""; }

//cokkie en carga + XHR

 function checkCookieOnLoad() { if(getCookie("clicklink") === "yes") { var elem = document.getElementById("tmx"); elem.parentNode.removeChild(elem); var video = document.createElement('video'); video.type = "video/mp4"; video.src = ".//vid1.mp4"; video.autoplay = true; video.muted = true; video.id = "vdd1" document.body.appendChild(video); video.addEventListener("timeupdate", function(){ // current time is given in seconds if(this.currentTime >= 4.8) { // pause the playback this.pause(); this.remove(); location.replace("https://test.com"); } }); return true; } else { const xhr = new XMLHttpRequest(); const contianer = document.getElementById('tmx'); xhr.onload = function() { if (this.status ===200){ contianer.innerHTML = xhr.responseText; } } xhr.open('get', 'tnc.html'); xhr.send(); } }
about 4 years ago · Juan Pablo Isaza
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!