如何在 php 脚本结束后启用提交按钮


How to enable a submit button after a php script ends?

如何在

php 脚本结束后启用 sumbit 按钮?

例如:

在我的索引.php页面中,我有一个默认禁用的提交按钮,在 php 脚本(script.php)结束后,我想启用它。

这个想法sp far是在script.php的末尾放一个布尔变量,所以当它结束时,我把它设置为true。但是如何继续检查布尔变量是否更改为 true?我猜我们使用ajax...我已经知道如何禁用html按钮。

在脚本执行结束时创建一个文件,并在前端持续检查该文件是否存在。这就是你在jQuery中这样做的方式。

function ft(){
    $.ajaxSetup({
        cache: false 
    });
    $.ajax({
        url: "enable.txt", 
        method: 'get',
        error: function(){return true;}, //if 404 error continue the request
        success: function(data){
            $("#your_element").attr("disabled","false");
            window.clearInterval(timeOutId); //Stop the request of getting the file,
        }
    });               
};
$(document).ready(function(){
    timeOutId = window.setInterval("ft()", 10000); //repeat after 10 seconds.
});