You can do a head ajax request and read the content before doing anything else:
`$.ajax({type: "HEAD", url, url}).done(function (data) { ...do the rest... })`