Copy link to clipboard
Copied
Hi everyone,
I'm trying to generate a button in my form to allow users to check if they downloaded the latest version online by implementing the code below. For some reason, it doesn't work. I defined the URL of the server where the latest form version is hosted and the latest file name allocated, but it still doesn't run. Any idea why?
----------------------------
var versionCheckUrl = "https://example.com/checkformversion";var xhr = new XMLHttpRequest();
xhr.open("GET", versionCheckUrl, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
var latestVersion = xhr.responseText;
var currentVersion = this.getField("versionField").value;
if (latestVersion === currentVersion) {
app.alert("You have the latest version of the form.");
} else {
app.alert("A newer version of the form is available. Please download it from our website.");
}
}
};
xhr.send();
Copy link to clipboard
Copied
Check the JavaScript console (ctrl-j) for errors.
Copy link to clipboard
Copied
Thanks @Bernd Alheit I couldn't figure out the issue. Is there easier way to apply so far. As I may over complicating the solution.
Copy link to clipboard
Copied
To start, besides the bad formatting, this is not Acrobat JavaScript. If you had looked in the console window you would have seen an error reported on the first line. Something like this;
ReferenceError: XMLHttpRequest is not defined
Where did you get this code?
See the Acrobat JavaScript reference for a list of actual objects and functions in the Acrobat JavaScript model.
https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/index.html
Copy link to clipboard
Copied
Thanks @Thom Parker, to this stage my knowedge is limited 😞
I didn't know it was that complicated. I had a problem where users download old versions and they don't check back for updates. I'm struggling with this, so I thought if something could check the name of the file with the version and alert users, that would be great. The code from a friend.
Copy link to clipboard
Copied
There is a way to do this. And it's not that complicated.
Use the doc.submitForm() function. You're server side script will need to be modified to return a data format that is acceptable to Acrobat, such as XML, XFDF, or FDF.
Copy link to clipboard
Copied
Thanks, @Thom Parker and @Bernd Alheit , for taking the time to respond to my question. I'll leave it here because I don't have enough knowledge to implement that.