From ProtoScript
Contents |
YUI:FetchHtml Behavior
Fetches HTML by using an Ajax request and populates an element or elements with the result.
Example
$proto('#portfolio-list', {
FetchHtml: {
url: 'getTrips.php?query=Amsterdam&start=1&results=4'
}
};
An Ajax request is made to a URL that fetches 4 trips from the Yahoo! Trip Planner Web service. The PHP returns the results as a block of HTML. The results are set as the HTML (using innerHTML) for the element denoted by '#portfolio-list'.
The url is limited to the same domain as the requester.
Attributes
| Name | Description | Default | Valid Values | Example |
|---|---|---|---|---|
| target | Selected element or elements to place the returned HTML result inside (using innerHTML). | No value. If no value supplied, use the last targeted element. If value is supplied, use the element(s) selected by the target instead. See Element Scope | String value denoting an interface element. See Selecting Elements|FetchHtml: { target: '#mytrips' } - Place result in the element with the ID = 'mytrips' | |
| url | URL to make the Ajax request from | Any URL that can return valid HTML. The URL must be from the same domain as requestor. | no default value, but is required | FetchHtml: { url: 'getTrips.php?
query=Amsterdam&start=1&results=4' }</nowiki> |
Callbacks
| Name | Description |
|---|---|
| onSuccess | If the request is successful then onSuccess is called. |
| onFailure | If the request is not successful then onFailure is called. |
Demo
See FetchHtml Demo
