|
XML data can be requested from a server using an HTTP request.
The Browser Request
An HTTP request from the browser, can request XML from a server:
var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
objHTTP.Open('GET','httprequest.asp',false)
objHTTP.Send()
To view the result from the request, you can display the result
in your browser:
document.all['A1'].innerText= objHTTP.status document.all['A2'].innerText=
objHTTP.statusText document.all['A3'].innerText=
objHTTP.responseText
Communicating with the Server
With HTTP requests you can "communicate" with a server.
In the example the response is "faked" on the server with this
ASP code:
<% Response.ContentType="text/xml"
txt="<answer><text>12 Years</text></answer>"
response.write(txt) %>
So, the answer will always be 12 years, no matter what question
is asked. In real life, you have to write some code to analyze
the question and respond with a correct answer.
|