jQuery Validation plugin: submitHandler not preventing default on submit when making ajax call to servlet - return false not working

前端 未结 5 1260
渐次进展
渐次进展 2021-01-14 06:35

I have a simple form that uses jquery and a servlet. The jquery makes an ajax call to the servlet, the servlet makes some server side calculations, then displays the result

5条回答
  •  遥遥无期
    2021-01-14 07:21

    $('#post_form_jason_data').click(function() {
    $('#myform').validate({ 
        rules: {
            txtwtrt: {
                required: true
               // email: true
            },
            tax_name: {
                required: true,
                minlength: 5
            },
        tax_rate: {
                required: true
                //minlength: 5
            }
        }
    });
    alert('insert the value');
    if (('#myform').valid()){
    
    
            $.ajax({
                url: "swt_tax_add.html",
                type: 'POST',
                data : $('#myform').serialize(),                
                success: function(msg) {
                    window.location.href='swt_tax/?st=1';
                    $('#message').html(msg);            
    
                }
    
            });
        }
    
            return false;
        });
    

提交回复
热议问题