Jaxer.Web : Object
Return to: Jaxer Framework index

Namespace object holding functions and members used to resolve and fetch web resources. Fetching is done via XMLHttpRequests.

Platform Support

Jaxer Server Framework Jaxer Client Framework
1.0 no

Functions

Method Action Jaxer Server Framework Jaxer Client Framework
static getDefaultReferenceUrl() : String
Returns the URL to be used as a reference for resolving relative URLs if no other reference is given

(Advanced)
Show Details 1.0 no

Returns
String The absolute URL

static get(String url, Jaxer.XHR.SendOptions options) : Object
Fetch a document from a URL by resolving it to a local file (if it starts with file://) or by a GET command.
Show Details 1.0 no

Parameters
String url The URL to fetch, which may be a file:// URL if desired. This will first be resolved by Dir.resolve() or Web.resolve().
Jaxer.XHR.SendOptions options Options for finer control of how the request is made.

Returns
Object The text of the requested document, or the XML DOM if the response was an XML document. Set the "as" property in the options argument to "text" or "xml" to force what is returned. An Exception is thrown if not successful.

static open(String url, [String data,] Jaxer.Sandbox.OpenOptions options) : Jaxer.Sandbox
GET or POST data to a URL, loading the result into the window of a new Jaxer.Sandbox object.
Show Details 1.0 no

Parameters
String url The URL of the page to GET or POST to. This will first be resolved by Web.resolve().
String data (optional)The data to submit, if any. If this parameter is omitted or is null, a GET is used; otherwise a POST is used. If this is a string, it should usually be a query string in a format (name1=value1&name2=value2) suitable for a Content-Type of 'application/x-www-form-urlencoded'. If an object, its enumerable properties will be used to construct the query string.
Jaxer.Sandbox.OpenOptions options Options for finer control of how the request is made.

Returns
Jaxer.Sandbox The Sandbox, which will usually have a window and document in it (if the request was successful and returned an HTML page)

See Also

Jaxer.Sandbox

static post(String url, String data, Jaxer.XHR.SendOptions options) : Object
POST data to a URL and return the response web page.
Show Details 1.0 no

Parameters
String url The URL of the page to POST to and fetch. This will first be resolved by Web.resolve().
String data The data to submit. If a string, it should be a query string in a format (name1=value1&name2=value2) suitable for a Content-Type of 'application/x-www-form-urlencoded'. If an object, its enumerable properties will be used to construct the query string.
Jaxer.XHR.SendOptions options Options for finer control of how the request is made.

Returns
Object The text of the requested document, or the XML DOM if the response was an XML document. Set the "as" property in the options argument to "text" or "xml" to force what is returned. An Exception is thrown if not successful.

static resolve(String url, [String referenceUrl]) : String
Resolves a URL to an absolute URL (one starting with protocol://domain...) To resolve a relative URL (with or without a leading /), use a current document or callback for reference. Uses the base href of the current document, if specified. If Jaxer.Config.REWRITE_TO_FILE_URL_REGEX exists and matches the url, the url is resolved as a file-type URL: it will use the given referenceUrl if it's already a file-based one, otherwise it will use the Jaxer.request.documentRoot for an absolute url or Jaxer.request.currentFolder for a relative url. If Jaxer.Config.REWRITE_RELATIVE_URL exists (and we're not dealing in file-based URLs), its value is used to rewrite the relative url -- replacing Jaxer.Config.REWRITE_RELATIVE_URL_REGEX pattern, if it exists, else replacing http [ s ] :// followed by anything but a slash.
Show Details 1.0 no

Parameters
String url The URL to resolve
String referenceUrl (optional)An optional reference URL to use, overriding the built-in logic

Returns
String The fully-resolved URL, or the original URL if the input was already an absolute URL

static send(String url, [String method,] [String data,] [Jaxer.XHR.SendOptions options]) : Object
A generalized method to access a web URL via the built-in XMLHttpRequest object.
Show Details 1.0 no

Parameters
String url The url to access
String method (optional)Usually 'GET' (default) or 'POST'
String data (optional)Use for POST submissions, or for GET requests if the url does not already contain the data. This may be a string (usually of the form name1=value&name2=value), or an object whose name->value property pairs will be used to construct such a string.
Jaxer.XHR.SendOptions options (optional)Options for finer control of how the request is made.

Returns
Object The text of the requested document, or the XML DOM if the response was an XML document. Set the "as" property in the options argument to "text" or "xml" or "e4x" to force what is returned. An Exception is thrown if not successful.

aptana_docs