likelian / MusicTXT

A text-based online music notation tool
http://www.musictxt.org/
3 stars 0 forks source link

需要刷新,深度刷新,延迟 #1

Closed likelian closed 2 years ago

likelian commented 2 years ago

前端监听数据库

talker93 commented 2 years ago

这个问题解决了,不过没有用到数据库,就是用js监听ajax那个xhr对象的状态。 当状态变成load的时候,就刷新一下iframe。 https://github.com/likelian/MusicTXT/blob/main/musictxt/ponds/static/style.js

xhr.addEventListener('load', function(e) {
    document.getElementById("runStatus").innerHTML = "Success!";
    console.log(xhr.response);
    document.getElementById("myIframe").contentWindow.location.reload();
});
xhr.addEventListener('loadstart', function(e) {
    document.getElementById("runStatus").innerHTML = "Loading...";
});
xhr.addEventListener('error', function(e) {
    alert('request failed for some reason, please look into the sendText()');
});