static
Class jsbeans.Request
Utility to manage urls, request parameters and AJAX calls.
Properties
The current query string (parameter name-value pairs)
Methods
static
boolean
containsParameter
(
parameterName
)
Checks if current url contains a {@param} parameterName
parameter.
- Parameters:
-
parameterName
<String>
- Returns:
boolean
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
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
.
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
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
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
static
XmlHttpRequest
getRequestObject
(
)
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
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