Namespace: ServiceType

html.ServiceType

The collection of built-in service types of html.js module.
Since:
  • 0.1.0
Source:

Members

(static) AJAX

Service type that enables delivery of requests from a browser to a server as an AJAX HTTP request. Each service of this type should have the following properties specified in its service config object (the second argument of the service registration register function):

- (string) type - set to html.ServiceType.AJAX
- (string) url - the URL of the server-side service handler
- (string) method - the HTTP method to be used
- (boolean) async - [optional] whether to send HTTP request synchronously or asynchronously (default async = true)
- (string) user - [optional] user performing the action
- (string) password - [optional] user's password
- (Object) headers - [optional] request headers to add to the HTTP request using setRequestHeader method
- (Function) beforeSend - [optional] function that modifies the request prior to sending (request would be provided to it as an argument)

Source:
Example

Example of ServiceType.AJAX service

services.register('myAjaxService', {
    type: html.ServiceType.AJAX,
    url: 'services/service-x',
    method: 'post',
    headers: {
        'Cache-Control' : 'no-cache'
    },
    beforeSend: function(xHttpReq){
        xHttpReq.setRequestHeader('Keep-Alive', '300');
    }
});

(static) AJAX_JQUERY

Service type that enables ajax-based delivery of requests through the jQuery API. Each service of this type should have the service config object (the second argument of the service registration register function) having the type property set to html.ServiceType.AJAX_JQUERY and other properties specified as properties of the settings object in jQuery's ajax function (see http://api.jquery.com/jquery.ajax/). Note that dataType: 'json' is hardcoded into the jQuery's settings object.
Source:
Example

Example of jQuery AJAX service

services.register('myJQueryService', {
    type: html.ServiceType.AJAX_JQUERY,
    // the type is followed by jQuery-specific properties of the 'settings' object
    // dataType: 'json' is assumed
    url: "some.php",
    method: "POST",
    accepts: {
        mycustomtype: 'application/x-some-custom-type'
    }
});

(static) AJAX_URL_ENCODED

Service type that enables delivery of requests from a browser to a server as an AJAX HTTP request where all the requests are encoded in a URL's query string (using encodeURIComponent function, in the form of encodedRequests=...). Each service of this type should have the following properties specified in its service config object (the second argument of the service registration register function):

- (string) type - set to html.ServiceType.AJAX_URL_ENCODED
- (string) url - the URL of the server-side service handler
- (string) method - the HTTP method to be used
- (boolean) async - [optional] whether to send HTTP request synchronously or asynchronously (default async = true)
- (string) user - [optional] user performing the action
- (string) password - [optional] user's password
- (Object) headers - [optional] request headers to add to the HTTP request using setRequestHeader method
- (Function) beforeSend - [optional] function that modifies the request prior to sending (request would be provided to it as an argument)

Source: