{:action => "nameChoices"} ) %> class FooController < ApplicationController def nameChoices prefix = params[:form][:userName]... compute names... render :partial => "name_list", :layout => false end Name: Al Alfred Wang Alice Washington Allen Williams Allison McLean Alok Chandra"> {:action => "nameChoices"} ) %> class FooController < ApplicationController def nameChoices prefix = params[:form][:userName]... compute names... render :partial => "name_list", :layout => false end Name: Al Alfred Wang Alice Washington Allen Williams Allison McLean Alok Chandra">
Download presentation
Presentation is loading. Please wait.
1
CS 142 Lecture Notes: AjaxSlide 1 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
2
CS 142 Lecture Notes: AjaxSlide 2 JSON Example {name: "Alice", gpa: 3.5, friends: ["Bill", "Carol", "David"]}
3
Slide 3 Higher-Level AJAX Example... <%= observe_field( :form_userName, :update => "completionMenu", :url => {:action => "nameChoices"} ) %> class FooController < ApplicationController def nameChoices prefix = params[:form][:userName]... compute names... render :partial => "name_list", :layout => false end Name: Al Alfred Wang Alice Washington Allen Williams Allison McLean Alok Chandra
4
Slide 4 Higher-Level AJAX Example... <%= observe_field( :form_userName, :update => "completionMenu", :url => {:action => "nameChoices"} ) %> class FooController < ApplicationController def nameChoices prefix = params[:form][:userName]... compute names... render :partial => "name_list", :layout => false end Name: Al Alfred Wang Alice Washington Allen Williams Allison McLean Alok Chandra
5
CS 142 Lecture Notes: AjaxSlide 5
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.