0

我正在尝试编写一个简单的插件来附加到表单提交,就像一个更简单的版本:http: //jquery.malsup.com/

这是我的代码:http: //jsfiddle.net/RYh33/6/

go() 函数在文档就绪外部定义,然后在文档就绪时立即调用。此调用有效并返回状态 200。

只要您单击其中一个提交按钮,Firebug 就会显示 POST 已中止。到底是怎么回事?

4

1 回答 1

1

如果您要为表单提交编写自定义内容,我相信您需要有一个返回值。举个例子,看看我前几天写的一段话:

$('#cmdform').submit(function(e){
    if ($('#param').attr('disabled') != 'disabled' && $.trim($('#param').val()) == ''){
        // This interrupts the form submit
        e.preventDefault();
        alert('Enter the required parameter first');
        $('#param').val('');
        return false;
    } else if ($('#router option:selected').val() == 'none'){
        e.preventDefault();
        alert('Choose a proper device');
        $('#param').val('');
        return false;
    } else {
        $('#output').empty();
        $('#output').append('<p>Loading, please wait....</p>');
        $('#execute').attr('disabled', 'disabled');
        return true;
    }
});

正如您在此处看到的,我的提交函数的每条路径都返回 true 或 false。试试看,看看它会把你带到哪里。

于 2012-08-30T14:14:40.490 回答