From SpinetiX Support Wiki

Jump to: navigation, search

This page is related to jSignage API.

Ajax methods

The following Ajax methods are implemented in jSignage:

  • $.ajax( url, [settings] )
    Low-level interface with full control over HTTP operations. Note that only the GET and POST HTTP methods are supported by the SVG Tiny 1.2 µDOM.
  • $.get( url, [data], success( data,textStatus ), [dataType] )
    Load data from the server using an HTTP GET request.
  • $.getJSON( url,[data], success( data, textStatus ) )
    Load JSON-encoded data from the server using an HTTP GET request.
  • $.getAndParseFeed( dataSourceObject, callback, useGetURL )
    Load data from the server using an HTTP GET request and then parse the feed data.
  • $.post( url, [data], success( data, textStatus ), [dataType] )
    Load data from the server using an HTTP POST request.
  • $.setGetURLFlags( flags )
    Sets the global caching flags used for the HTTP GET request. The flags are detailed under the getURL() function.
Note Note:
Learn about Ajax or see jQuery documentation for reference about these methods.
Note Warning:
When using AJAX methods in browsers, the security settings may prevent data from being loaded if it does not comes from the same server as the file being displayed. There are no issues on the HMP devices or Elementi, but for cross-browser / player compatibility, JSONP extension can be used to overcome the cross-domain restrictions imposed by browsers' same-origin policy.


Request an RSS feed

Request an RSS feed and parse it using parseRSS:

   function( data ) {
     var news = $.parseRSS( data );

Notice that you must use set the dataType parameter to 'text' in order to prevent the feed from being parsed to XML as a result of auto-detection.

Query a database

Query a database via a PHP script located on the server and returning the data as JSON:

   { table: 'prices', type: 'coffee', subtype: 'latte' },
   function( response ) {
     $('#price').clearText().tspan( response.price );
Update a Shared Variable via RPC

To set / update a Shared Variable via RPC, an AJAX POST call to http://HMP_address/rpc/can be used:

$.ajax( { 
  type: "POST", url: "http://HMP_address/rpc", contentType: 'application/json',
  data: JSON.stringify( {
    method: "webstorage_set", params: [[ { name: "var1", value: "Hello" } ]], id: 1
  } )

See also

This page was last modified on 22 February 2019, at 12:27.