jsbeans

jsbeans  1.0.0

jsbeans > jsbeans > jsbeans.Request
Search:
 
Filters

static Class jsbeans.Request

Utility to manage urls, request parameters and AJAX calls.

Properties

jsbeans.Request.QUERY_STRING - static final {String}

The current query string (parameter name-value pairs)

Methods

containsParameter

static boolean containsParameter ( parameterName )
Checks if current url contains a {@param} parameterName parameter.
Parameters:
parameterName <String>
Returns: boolean

GET

static void GET ( url , callback )
AJAX call via GET method.
Parameters:
url <String> the url to GET. It appends a new parameter on every call to prevent browser's cache.
callback <Function> the callback with responseText and XmlHttpRequest itself as arguments.
Returns: void

getContextPath

static String getContextPath ( )
The context path is the base url of a site. This is the javascript way to get it.
Note that some DNS rules may conflict with this method.
It uses window.location.pathname.
Returns: String

getHash

static String getHash ( )
The hash is an anchor portion of current url. E.g. <a href="index.html#this_is_a_hash">some link</a>
Returns: String
current hash value ('#' excluded) or null

getHashParameter

static String getHashParameter ( parameterName )
Returns the (URI decoded) value of the {@param} parameterName for the current hash supposed in the form of GET urls (e.g. #par1=one&par2=two) or null otherwise.
Parameters:
parameterName <String>
Returns: String

getParameter

static String getParameter ( parameterName )
Returns the (URI decoded) value of the {@param} parameterName for the current url or null otherwise.
Parameters:
parameterName <String>
Returns: String

getRequestObject

static XmlHttpRequest getRequestObject ( )
Returns: XmlHttpRequest

POST

static void POST ( url , data , callback )
AJAX call via POST method.
{@param} data may be omitted in favour of {@param} callback passed directly as second argument.
Parameters:
url <String>
data <String> it will be passed 'as is' on the send.
callback <Function> the callback with responseText and XmlHttpRequest itself as arguments.
Returns: void

send

static void send ( xhr , callback )
If you want to directly call a send.
Parameters:
xhr <XmlHttpRequest> you may use jsbeans.Request.getRequestObject()
callback <Function> the callback with responseText and XmlHttpRequest itself as arguments.
Returns: void


Copyright © 2016 Francesco Mele. All rights reserved.