• Components
    • Mixins

Modules

The following methods and properties are located under pz.http namespace, or via @plazarjs/http module depending on the environment.
Properties
Name
Description
defaultDataType
The format of the response.

Default: 'json'
latestRequestId internal
Unique Id (guid) of the last executed request.
Methods
Name
Description
abort (all)
Aborts latest or all requests that are currently executing.
delete (options)
  • Creates and invokes an AJAX DELETE request based on passed options.
  • Parameters:
    • options: Object
  • Returns: created request
  • This is a shorthand of pz.http.request method.
get (options)
  • Creates and invokes an AJAX GET request based on passed options.
  • Parameters:
    • options: Object
  • Returns: created request
  • This is a shorthand of pz.http.request method.
post (options)
  • Creates and invokes an AJAX POST request based on passed options.
  • Parameters:
    • options: Object
  • Returns: created request
  • This is a shorthand of pz.http.request method.
put (options)
  • Creates and invokes an AJAX PUT request based on passed options.
  • Parameters:
    • options: Object
  • Returns: created request
  • This is a shorthand of pz.http.request method.
request (options)
  • Creates and invokes an AJAX request based on passed options.
  • Parameters:
    • options: Object
  • Passed options can contain the following properties:
    • url: String
    • method: String
    • data: Object (optional) This is internally converted to a json string.
    • dataType: String (optional) The format of the response, default: 'json'
    • success: Function (optional)
    • fail: Function (optional)
    • abort: Function (optional)
    • params: Object (optional) A key/value pairs which will be used to create a routed url. Useful when invoking a get request, for example.
    • headers: Object (optional) A key/value pairs which will be used to set the request headers.
    • timeout: Number (optional) A number of milliseconds this request can take before terminating. After a timeout, abort callback is called.
  • Returns: created request
  • Example usage:
  •             pz.http.request({
                
      url: 'my-url',
      method: 'POST',
      success: function(response) {
        // implementation
      },
      fail: function(err) {
        // implementation
      }
    });

    // with params
    pz.http.request({
      url: 'my-url/{id}/{name}',
      method: 'GET',
      params: {
        id: 1,
        name: 'John'
      }
    });

    // with headers
    pz.http.request({
      url: 'my-url',
      method: 'POST',
      headers: {
        'Content-Type''application/json;charset=UTF-8'
      }
    });