Created
May 2, 2020 16:30
-
-
Save vfontjr/f05ed1ee7b94f7f3c5adab6810361fdc to your computer and use it in GitHub Desktop.
Source code for https://victorfont.com/formidable-pro-invoke-ajax-submit/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function ($) { | |
"use strict"; | |
function set_form_fields(data) { | |
$("#html_display_element").html(data); | |
$("#field_confirm_value").attr("value", data ); // One way to set a value. Could also use $("#field_confirm_value").val( data ); | |
} | |
$("#btnSubmit").on( "click", function (e) { | |
e.preventDefault(); | |
var confirmation_req = $.ajax({ | |
type: 'GET', | |
url: 'my_processing_script', | |
dataType: "text", | |
contentType: "text/xml", | |
data: { FormXml: strXml }, | |
dataFilter: function (data, type) { | |
var start = data.search('">') + 2, strlen = data.search('</long>') - start; | |
return data.substr(start, strlen); | |
} | |
}); | |
confirmation_req.done(function(data) { set_form_fields(data); }); // fires on successful return of data | |
confirmation_req.always(function() { $("#form_key").submit(); }); // always fires on completion of ajax request regardless of success or failure | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment