Class: Request.HTML

Request Specifically made for receiving HTML.

Extends:

Request

Синтаксис:

var myHTMLRequest = new Request.HTML([options]);

Аргументы:

  1. options - (object, optional) See options below. Also inherited are all the options from Request.

Options:

  • update - (element: defaults to null) The Element to insert the response text of the Request into upon completion of the request.

Events:

success

  • (function) Function to execute when the HTML request completes. This overrides the signature of the Request success event.
Signature:
onSuccess(responseTree, responseElements, responseHTML, responseJavaScript)
Аргументы:
  1. responseTree - (element) The node list of the remote response.
  2. responseElements - (array) An array containing all elements of the remote response.
  3. responseHTML - (string) The content of the remote response.
  4. responseJavaScript - (string) The portion of JavaScript from the remote response.

Возвращает:

  • (object) A new Request.HTML instance.

Примеры:

Simple GET Request:

var myHTMLRequest = new Request.HTML().get('myPage.html');

POST Request with data as String:

var myHTMLRequest = new Request.HTML({url:'myPage.html'}).post("user_id=25&save=true");

Data from Object Passed via GET:

//Loads "load/?user_id=25".
var myHTMLRequest = new Request.HTML({url:'load/'}).get({'user_id': 25});

Data from Element via POST:

HTML
<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>
JavaScript
//Needs to be in a submit event or the form handler.

var myHTMLRequest = new Request.HTML({url:'save/'}).post($('user-form'));

Смотрите также:

Request

Hash: Element.Properties

see Element.Properties

Element Property: load

Setter

Sets a default Request.HTML instance for an Element.

Синтаксис:

el.set('load'[, options]);

Аргументы:

  1. options - (object) The Request options.

Возвращает:

  • (element) The target Element.

Пример:

el.set('load', {evalScripts: true});
el.load('some/request/uri');

Getter

Returns either the previously set Request.HTML instance or a new one with default options.

Синтаксис:

el.get('load', options);

Аргументы:

  1. 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');

Native: Element

Custom Native to allow all of its methods to be used with any DOM element via the dollar function $.

Element Method: load

Updates the content of the Element with a Request.HTML GET request.

Синтаксис:

myElement.load(url);

Аргументы:

  1. url - (string) The URL pointing to the server-side document.

Возвращает:

  • (element) The target Element.

Пример:

HTML
<div id="content">Loading content...</div>
JavaScript
$('content').load('page_1.html');

Смотрите также:


Эта документация распостраняется на правах Attribution-NonCommercial-ShareAlike 3.0 License.
Оригинал документации на английском.
© Linux.ria.ua, 2008-2024