mantraapiajax@1.0.0

mantraapiajax@1.0.0

mantraapiajax Mantra component. Defines a number of useful methods to MantraAPI client object to make ajax calls.

By @mantradev

Install with:

$ mantrad download-component mantraapiajax@1.0.0

Or install last version with:

$ mantrad download-component mantraapiajax

README.md

mantraapiajax Mantra component

This component simply defines a js to add some ajax methods to MantraAPI client object.

js file "mantraapiajax.mantrapiajax" should be included.

This components depends on jQuery.

These are the useful methods.

MantraAPI.PostAsync( component, command, data )

Makes a call to an specific command for a component, including data to send in a parameter called "mastraPostData"

Parameters:

  • component: name of the component to call
  • command: name of the command to call
  • data: parameters to send. The parameters will be sent in this json object:
{
    "mantraPostData": <data>
}

Returns a promise object.

MantraAPI.RedirectTo( url )

Redirect current web location to other indicated in the url.

MantraAPI.Post( apicall, data, onsuccess, onerror )

Same than PostAync but indicating callback funcions to be called when success (onsuccess parameter) and when error (onerror parameter ).

MantraAPI.Get( apicall, onsuccess, onerror )

Makes a simple GET call according to the parameters:

  • apicall: <url to call, including data queries if any>
  • onsuccess: <callback function to be called with the response>
  • onerror: <callback function to be called when error>