function ajaxGetRate(node)
{
// 1. initialize XMLHttp object
if ( window.XMLHttpRequest ) // Mozilla browser
{
httpRequest = new XMLHttpRequest();
}
else if ( window.ActiveXObject) // IE browser
{
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
// 2. specify the response processing function
// onreadystatechange:
httpRequest.onreadystatechange = processRequest;
// 3. send http request
httpRequest.open('GET', 'http://localhost/start', true);
httpRequest.send(null);
}
function processRequest()
{
// readyState:
// 0: request not initialized
// 1: server connection established
// 2: request received
// 3: processing request
// 4: request finished and response is ready
if ( httpRequest.readyState == 4 )
{
if ( httpRequest.status == 200 )
{
document.getElementById("msg").innerHTML = request.responseText;
}
}
}
No comments:
Post a Comment