Get content from a page using XMLHttpRequest

0

I'm using XMLHttpRequest to get content from a page. I have code that works to create the object and submit showing alert . I wanted to get the contents of a page in assync mode.

This is the code creating the object:

var xhr_object = null;

    if(window.XMLHttpRequest) // Firefox
       xhr_object = new XMLHttpRequest();
    else if(window.ActiveXObject) // Internet Explorer
       xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
    else { /
       alert("Nao suporta XMLHTTPRequest...");
       return;
    }

    //methodo de transmicao
    //url
    // true mode asynchrone
    xhr_object.open("GET", "http://page.htm", true);

    //4 (complete) 
    xhr_object.onreadystatechange = function() { 
        if(xhr_object.readyState == 4) alert("Request!");
    }

    //executar request
    xhr_object.send(null);
    
asked by anonymous 05.01.2015 / 13:10

0 answers