Mystogan Mystogan - 1 year ago 129
Javascript Question

Check if file (ClickOnce) exists using jQuery

I am trying to find out whether or not a file exists, before trying to download it. The file is a ClickOnce application.

I have already tried the following code, but this does not work (maybe because the URL is on a different server and domain?);

url: '',
type: 'HEAD',
error: function()
//File does not exist
success: function()
// File exists

Is there another solution, or is there a means to get this one to work?

Answer Source

Yes, this should not work if the URL is on a different server. If you want to make this work, you will need control over the server where the URL is downloaded from. If so, you should set the Access-Control-Allow-Origin header to the name of the server from which your JavaScript is loaded.

See Stack Overflow question jQuery AJAX cross domain for more details.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download