JavaScript/jQuery check broken links -


I have developed a small javascript / jquery program to use the collection of PDF files for internal use. And if I really existed the file then I should be informed about a PDF file.

Is there any way to determine the program that the link to the file is broken? if so, how?

Any guide or suggestion is deployed.

If the files are on the same domain, then you can use AJAX to test for your survival As it has been said; However, you should not use the GET method, simply HEAD and then the HTTP status for expected value (200, or less 400 ).

It was a but it just did not seem to be a head. Instead, a simple method is given here:

  function urlExists (url, callback) {var xhr = new XMLHttpRequest (); Xhr.onreadystatechange = function () {if (xhr.readyState === 4) {callback (xhr.status & lt; 400); }}; Xhr.open ('HEAD', URL); Xhr.send (); } UrlExists (someUrl, function (present) {console.log ('"% s" exists?', Some url exists,;)});  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -