wildcard()route which will create some default
GETroutes for the
controller/actionpattern, but we'll add a new route here just for practice:
helloaction inside the
clickevent of the hyperlink, which will make an asynchronous request to the
helloaction in the
successblock inserts keys from the response into the empty
pblocks in the calling view. (You may have been wondering about those when you saw the first example. Mystery solved.)
config()method, we use the provides() function to indicate that we want all actions in the controller to be able to respond with the data in HTML or JSON formats. Note that the client calling the action can request the type by passing a URL parameter named format or by sending the
formatin the request header.
greetingstruct as JSON automatically and send it back to the client. If the client requested HTML or the default of none, Wheels will process and serve the view template at
views/say/hello.cfm. For more information about provides() and renderWith(), reference the chapter on Responding with Multiple Formats.
TIME(all caps). Unless you like turning caps lock on and off, you can see how that would get annoying after some time.
Alert me!link, your say controller will respond back to you the serialized message via AJAX. jQuery will parse the JSON object and populate the
pwith the appropriate data.