Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active July 2, 2021 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/5fa27541f6c463b98db2419d28819f9a to your computer and use it in GitHub Desktop.
Save bjoerntx/5fa27541f6c463b98db2419d28819f9a to your computer and use it in GitHub Desktop.
function submitform() {
// validate forms
var valid = TXDocumentViewer.forms.validate();
if (valid === false) { // not valid
$('.alert-info').text(
"Document contains invalid form fields.").show().delay(5000).fadeOut();
return;
}
// -> valid
// get the form values
var formsJson = JSON.stringify(TXDocumentViewer.forms.getValues());
// send values to controller
var serviceURL = "@Url.Action("FormValues", "Home", new { username = Model.Username })";
$.ajax({
type: "POST",
url: serviceURL,
contentType: 'application/json',
data: formsJson,
success: successFunc,
error: errorFunc
});
function successFunc(data, status) {
$('.alert-info').text(
"Thanks. Your document has been submitted!").show().delay(5000).fadeOut();
TXDocumentViewer.downloadDocument(TXDocumentViewer.StreamType.AdobePDF, true);
}
function errorFunc() {
$('.alert-info').text("Oops! There was an error.").show().delay(5000).fadeOut();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment