帮我改一段代码 不用jquery: $#qrcodeqrcodewidth180height180texthttpsqralipaycombax04981uulaql98wrh200db; setTimeoutstop 300000; function stop clearIntervalpaid_timeout; var paid_timeout = se
以下是不使用jQuery的修改后的代码:
var qrcode = document.createElement("div"); qrcode.id = "qrcode"; document.body.appendChild(qrcode);
var qrcodeConfig = { width: 180, height: 180, text: "https://qr.alipay.com/bax04981uulaql98wrh200db" }; generateQRCode(qrcodeConfig);
setTimeout(stop, 300000);
function stop() { clearInterval(paid_timeout); }
var paid_timeout = setInterval(go, 3000);
function go() { var xhr = new XMLHttpRequest(); xhr.open('GET', window.location.href); xhr.onload = function() { if (xhr.status === 200) { var data = xhr.responseText; if (data.search(/<span\sclass=.paid.>/) !== -1) { clearInterval(paid_timeout); alert("支付完成"); window.location.href = "/cart.php?a=complete"; } } }; xhr.send(); }
function generateQRCode(config) { var qrcode = document.getElementById("qrcode"); var qrCodeInstance = new QRCode(qrcode, config); }
原文地址: https://www.cveoy.top/t/topic/jag3 著作权归作者所有。请勿转载和采集!