ajax basics n.
Download
Skip this Video
Download Presentation
AJAX Basics

Loading in 2 Seconds...

play fullscreen
1 / 4

AJAX Basics - PowerPoint PPT Presentation


  • 113 Views
  • Uploaded on

AJAX Basics. 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; } ...

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'AJAX Basics' - filia


Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
ajax basics
AJAX Basics

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;

}

State 4 means “done”

Response available as

raw text or XML

CS 142 Lecture Notes: Forms

higher level ajax example
Higher-Level AJAX Example

Watch this element

for change

<%= observe_field(

"userName",

:frequency => 0.25,

:update => "completionMenu",

:url => {:action => "nameChoices"}

) %>

Issue AJAX request here

Replace this element’s

innerHTML with response

CS 142 Lecture Notes: Forms

json example
JSON Example

{name: "Alice", gpa: 3.5,

friends: ["Bill", "Carol", "David"]}

CS 142 Lecture Notes: Forms

ad