On this Page

    http.responseText - get response

    Get response

    Syntax

    http.responseText

    Parameters

    http - is the variable name used in a prior call to new XMLHttpRequest;

    Returned Value

    The text that was returned from the http request. E.g. an HTML or XML file or just echoed output.

    Description

    After having created an XMLHttpRequest object, opened an URL, and issued that request (via send), you can get the response by examining the responseText property of the XMLHttpRequest object.

    Example

    Note that the async parameter of open is false since I want synchronous behavior. I want the get to have been done before I check responseText.

    var http = new XMLHttpRequest;
    http.open("GET", "http://www.docorigin.com/MyIp.php", false);
    http.send(null);
    
    var sResult = http.responseText;    // what was sent back
    _message("result='%s'", sResult);

    Results in: whatever the invoked, in this case PHP, responded with. In the MyIp.php example case that is something like: Your IP is: nn.nnn.n.nn

    See Also

    XMLHttpRequest