javascript - How to remove AJAX from jQuery validation plugin function -
this going stupid question have spent inordinate amount of time trying remove ajax part jquery validation plugin function below still have validation work. suffice haven't succeeded.
$(document).ready(function(){ $("#myform").validate({ debug: false, rules: { group: {required: true}, }, messages: { group: {required: " choose group."}, }, submithandler: function(form) { $('#results').html('loading...'); $.post('', $("#myform").serialize(), function(data) { $('#results').html(data); }); } }); });
so yeah, i'm dumb. can me out?
when send object back, send json object.
here's example we're going use serialized elements, conditionalize data, , send our new page.
<?php $name = $_post['name']; $email = $_post['email']; $phone = $_post['phone']; if(isset($name) && isset($email) && isset($phone)){ return json_encode(array('filled' => 'yes', 'loc' => 'newpage.php')); } ?>
then in validator, can parse data.loc
window.location
mimic redirect.
$(document).ready(function(){ $("#myform").validate({ debug: false, rules: { group: {required: true}, }, messages: { group: {required: " choose group."}, }, submithandler: function(form) { $('#results').html('loading...'); $.post('', $("#myform").serialize(), function(data) { if(data.filled == 'yes'){ window.location = data.loc; } }); } }); });
Comments
Post a Comment