Request Specifically made for receiving HTML.
var myHTMLRequest = new Request.HTML([options]);
- options - (object, optional) See options below. Also inherited are all the options from Request.
- evalScripts - (boolean: defaults to true) If set to true,
script
tags inside the response will be evaluated. This overrides thefalse
default from Request. - update - (element: defaults to null) The Element to insert the response text of the Request into upon completion of the request.
- append - (element: defaults to null) The Element to append the response text of the Request into upon completion of the request.
- (function) Function to execute when the HTML request completes. This overrides the signature of the Request success event.
onSuccess(responseTree, responseElements, responseHTML, responseJavaScript)
- responseTree - (element) The node list of the remote response.
- responseElements - (array) An array containing all elements of the remote response.
- responseHTML - (string) The content of the remote response.
- responseJavaScript - (string) The portion of JavaScript from the remote response.
- (object) A new Request.HTML instance.
var myHTMLRequest = new Request.HTML().get('myPage.html');
var myHTMLRequest = new Request.HTML({url:'myPage.html'}).post('user_id=25&save=true');
//Loads "load/?user_id=25".
var myHTMLRequest = new Request.HTML({url:'load/'}).get({'user_id': 25});
<form action="save/" method="post" id="user-form">
<p>
Search: <input type="text" name="search" />
Search in description: <input type="checkbox" name="search_description" value="yes" />
<input type="submit" />
</p>
</form>
//Needs to be in a submit event or the form handler.
var myHTMLRequest = new Request.HTML({url:'save/'}).post($('user-form'));
Sets a default Request.HTML instance for an Element.
el.set('load'[, options]);
- options - (object) The Request options.
- (element) The target Element.
el.set('load', {evalScripts: true});
el.load('some/request/uri');
Returns either the previously set Request.HTML instance or a new one with default options.
el.get('load', options);
- options - (object, optional) The Request.HTML options. If these are passed in, a new instance will be generated, regardless of whether or not one is set.
- (object) The Request instance.
el.set('load', {method: 'get'});
el.load('test.html');
//The getter returns the Request.HTML instance, making its class methods available.
el.get('load').post('http://localhost/script');
Custom Native to allow all of its methods to be used with any DOM element via the dollar function $.
Updates the content of the Element with a Request.HTML GET request.
myElement.load(url);
- url - (string) The URL pointing to the server-side document.
- (element) The target Element.
<div id="content">Loading content...</div>
$('content').load('page_1.html');