2.24. Giving instructions to the browser
Next we need to tell the browser what to do when it gets a response from the server. Remember, the browser will run the function we tell it about every time the ready state changes.
function getCustomerInfo() {
var phone = document.getElementById("phone").value;
var url = "lookupCustomer.php?phone=" + escape(phone);
request.open("GET", url, true);
request.onreadystatechange = updatePage;Here's the name of the function
that the browser should run whenever the ready state of the request object changes.
request.send(null)
;Be sure you set the onreadystatechange property before calling
send(),
so the browser knows what to do when it gets a response.
}
|