DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Aug 2007
    Posts
    1

    how to get header information of a website???

    var req = new XMLHttpRequest();
    req.open('GET', 'http://localhost/gp/index.php', false);
    req.send(null);

    if(req.status == 200) {
    alert(req.getResponseHeader('Content-type'));
    alert(req.getAllResponseHeaders());

    this code is working fine and giving the HEADER information;but if i change the URL and put http://www.google.com, then it is not working.........plzzzz i need help.

  2. #2
    Join Date
    Aug 2007
    Location
    Navi Mumbai
    Posts
    10

    RE: how to get header information of a website???

    Here is the code i tried with. It is running with other url but not with google. There may be some security risk for which you are not getting the result you want.

    <script>
    function xmlhttpPost()
    {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
    self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
    self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('GET', 'http://www.yahoo.com', true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
    if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200) {
    alert("Successful!");
    }
    }
    self.xmlHttpReq.send();
    }
    xmlhttpPost();
    </script>

    I hope this will help you

Similar Threads

  1. Get response/request Header information
    By tx12345 in forum VB Classic
    Replies: 2
    Last Post: 03-08-2007, 08:57 PM
  2. Replies: 4
    Last Post: 01-11-2007, 07:19 AM
  3. how can I best start a profitable website
    By john moyers M.D., PhD in forum Web
    Replies: 0
    Last Post: 06-04-2002, 09:12 AM
  4. Using VB to Read Tape Header information
    By Edwin Gomez in forum Talk to the Editors
    Replies: 0
    Last Post: 04-26-2002, 12:08 PM
  5. Replies: 3
    Last Post: 03-07-2001, 10:22 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links