您好我正在寻找帮助,在我的路线执行任务时显示加载gif。我已经有一个promise函数,它在测试运行时显示一条消息,并在完成后显示一条消息。我想我可以加载加载gif。我只是不确定如何通过此设置来解决这个问题。
HTML
<div class="container">
<img src="/images/loading.gif" height="32" width="32" id="loading-indicator" style="display: none ; margin: 0 auto;" />
</div>
服务器端,使用node.js with express。
router.get("/pos/fcsf_default", (req, res) => {
let test = "Was a super long string, edited to read easier."
let data = JSON.stringify(test);
sendToSlack("QA Hub - Automation - FCSF: " + req.user.username + " is running a rental with default values(This is a test)", "QA Hub - Automation", "auto_message_test" );
console.log("QA Hub - Automation - FCSF: " + req.user.username + " is running a rental with default values", "QA Hub - Automation", "auto_message_test");
var child = exec(`cd ${__dirname} & cd ../../ & cd automation_projects/fcsf/ & rake reserve`);
fs.writeFileSync(path.resolve(__dirname, "../", "temp/form-data.json"), (data));
myPromise(child).then(function (result) {
console.log('promise complete: ' + result);
sendToSlack("QA Hub - Automation - FCSF: " + "Test complete.");
console.log("QA Hub - Automation - FCSF: " + "Test complete.")
}, function (err) {
console.log('promise rejected: ' + err);
sendToSlack("Test failed");
});
req.flash("info", data + " test is being sent to process and run.");
res.redirect("/QAApplicationHub/Automation/dispatch_receive");
})
我读过使用ajax,这是最好的方法吗?我在想要做的是从服务器端检索图像,然后将其发送到前端,以便我可以在UI上显示它并从这条路线触发它....任何帮助都表示赞赏!< / p>