且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何后.submit重新加载页面()

更新时间:2023-12-02 10:52:04

您可以使用 重装() 方式:

You could use the reload() method:

$('#formname').submit(function() {
    $.post('load.php', $('#formname').serialize(), function(data) {
        if(data == '1') {
            window.location.reload();
        }
    });
    return false;
});

我特意删除了登录变量,因为它是没有必要的。 AJAX是异步的,所以退回此变量从提交处理程序是无用的,因为它不会被分配一个值呢。

I've intentionally removed the logon variable as it is not needed. AJAX is asynchronous so returning this variable from the submit handler is useless because it won't be assigned a value yet.