I have a page that uses jquery and I want to detect if an external file exists. If it does, I want to load it into a div, but if it doesn't, I want it to do nothing.
I'm using this code and it works to load the file, but it's loading a 404 error page if the external file does not exist. I am very new at jquery and would appreciate any help. Also, the method to check for the file needs to have rootdomain+ so that the code can be plugged into multiple sites with no edits.
$(function() {
$('#test').load('/pages/test.html');
});
Any help would be greatly appreciated. I've been searching for days but the only things I have found are head check scripts that don't have the option of doing nothing if the url isn't valid. I would love to know how to write this simple code myself but right now it's over my head. :)
Jeri