вот рабочий скрипт
<script type="text/javascript">
makeWebflowFormAjax = function( form, successCallback, errorCallback ) {
form.each(function(){
var form = $(this);
form.on("submit", function(){
var container = form.parent();
var doneBlock = $(".w-form-done", container);
var failBlock = $(".w-form-fail", container);
var action = form.attr("action");
var method = form.attr("method");
var data = form.serialize();
// call via ajax
$.ajax({
type: method,
url: "send.php",
data: data,
success: function (resultData) {
if (typeof successCallback === 'function') {
// call custom callback
result = successCallback(resultData);
if ( ! result ) {
// show error (fail) block
form.hide();
doneBlock.show();
failBlock.hide();
console.log(e);
return;
}
}
// show success (done) block
form.hide();
doneBlock.show();
failBlock.hide();
},
error: function (e) {
// call custom callback
if (typeof errorCallback === 'function') {
errorCallback(e)
}
// show error (fail) block
form.hide();
doneBlock.show();
failBlock.hide();
console.log(e);
}
});
// prevent default webdlow action
return false;
});
});
}
</script>
<script type="text/javascript">
makeWebflowFormAjax( $("form") );
</script>