Last active
July 2, 2021 15:48
-
-
Save bjoerntx/5fa27541f6c463b98db2419d28819f9a to your computer and use it in GitHub Desktop.
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
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