Class zebkit.io.HTTP <zebkit.io>

HTTP request class. This class provides API to generate different (GET, POST, etc) HTTP requests

Constructor:
zebkit.io.HTTP (url)

Parameters:
  • url <String>

    an URL to a HTTP resource




public <zebkit.DoIt> GET ([q])

Perform HTTP GET request with the given query parameters.


Parameters:
  • [q] <Object>

    a dictionary of query parameters


Returns: <zebkit.DoIt>

an object to get response


Example:
// GET request with the number of query parameters
var result = zebkit.io.HTTP("google.com").GET({
    param1: "var1",
    param3: "var2",
    param3: "var3"
}).then(function(req) {
    // handle response
    req.responseText;
}).catch(function(e)  {
    // handle error
    ...
});
public <zebkit.DoIt> POST (d)

Perform HTTP POST request with the give data to be sent.


Parameters:
  • d <String | Object>

    a data to be sent by HTTP POST request. It can be either a parameters set or a string.


Returns: <zebkit.DoIt>

an object to get response


Example:
// asynchronously send POST
zebkit.io.HTTP("google.com").POST("Hello").then(function(req) {
    // handle HTTP GET response ...
}).catch(function(e) {
    // handle error ...
});

Or you can pass a number of parameters to be sent:

// send parameters synchronously by HTTP POST request
zebkit.io.HTTP("google.com").POST({
    param1: "val1",
    param2: "val3",
    param3: "val3"
}).then(function(req) {
     // handle HTTP GET response ...
}).catch(function(e) {
     // handle error ...

});

public <zebkit.DoIt> SEND (method, url, [data])

Universal HTTP request method that can be used to generate a HTTP request with any HTTP method to the given URL with the given data to be sent asynchronously.


Parameters:
  • method <String>

    an HTTP method (GET, POST, DELETE, PUT, etc)

  • url <String>

    an URL

  • [data] <String>

    a data to be sent to the given URL


Returns: <zebkit.DoIt>

an object to handle result