Lecture Notes for CS142
Winter Quarter 2009
John Ousterhout
xhr = new XMLHttpRequest();
xhr.onreadystatechange = xhrHandler();
xhr.open("POST", url);
xhr.send(postData);
...
function xhrHandler() {
if (this.readyState != 4) {
return;
}
if (this.status != 200) {
// Handle error ...
return;
}
...
var text = this.responseText;
var document = this.responseXML;
}
send.
<%= observe_field :userName,
:frequency => 0.25,
:update => "completionMenu",
:url => {:action => "nameChoices"} %>
userName.
nameChoices action in the
current controller.
innerHTML
of the DOM element whose id is completionMenu.
{name: "Alice", gpa: 3.5,
friends: ["Bill", "Carol", "David"]}
<script> element:
target attribute to redirect the
POST response to a hidden iframe.