JS - check if an object or url exists
function urlExists(testUrl) {
var http = $.ajax({
type:"HEAD",
url: testUrl,
async: false
})
return http.status;
// this will return 200 on success, and 0 or negative value on error
}