http://www.headfirstlabs.com/books/hrajax/chapter01/
function getBoardsSold() {
createRequest();
var url = "getUpdatedBoardSales-ajax.php";
request.open("GET", url, true);
request.onreadystatechange = updatePage;
request.send(null);
}
function updatePage() {
if (request.readyState == 4) {
if(request.status ==200) {
var somevariable = request.responseText;
document.getElementById("Id").value = somevariable;
...
}
}
}
<--input --value="Show Me the Money" onclick="getBoardsSold();" type="button">
(more event handler)
<--input type="text" name="abc" onChange="getBoardsSold();" >
<--input type="text" name="abc" onFocus="foo();" >
<--input type="text" name="abc" onBlur="foo();" >
<--textarea name ="Id" id = "id" >
Any JavaScript in your web page that is not in a function gets run statically.
if (request == null) check out of function, will have the users know right away. (page 92)
No comments:
Post a Comment