Ajax Get Response Header
Response Header Example
Simple Ajax Example to get specific header information of any resource (html, text, jsp, servlet ) like Date, Last-Modified, Content-Type, Server etc.
<!DOCTYPE html> <html> <head> <script> function loadXMLDoc(url) { var u; if (window.XMLHttpRequest) { u=new XMLHttpRequest(); } else { u=new ActiveXObject("Microsoft.XMLHTTP"); } u.onreadystatechange=function() { if (u.readyState==4 && u.status==200) { document.getElementById('uk').innerHTML=u. getResponseHeader('Last-Modified'); } } u.open("GET",url,true); u.send(); } </script> </head> <body> <h1>specific header detail of the same file</h1> <div id="uk"></div> <button onclick="loadXMLDoc('index1.html')">Load Header info</button> </body> </html>
index1.html FILE
<html> <h1> This is index file</h1> </html>