jquery - "If default.html exists within folder then" function -
is there easy way script function based off file existing or not in particular folder? perhaps running 404 test against folder?
for example:
if default.html exists in child directory preview, ... else ...?
thanks help.
you this:
function exists(url) { var request = $.ajax({ type: 'head', async: false, url: url }); return request.status === 200; }
i wouldn't use this, however. it's blocking call , momentarily lock browser. use error
callback of ajax
function , make request asynchronous:
$.ajax({ type: 'head', url: url }).fail(function(request, status, error) { // error }).done(function(data, status, request) { // success });
better yet, don't @ all.
Comments
Post a Comment