Universeorange.com/Docs/

Priya library Function reference Global functions request

    ready(() => {
        request(String url, Object data, Function script);
    });

String url The url of the request
Object data The post data of the request, when empty a get will take place
Function script Code that has to run after the request response.

Example

    ready(() => {
        request('/user/', {"id": 1}, (url, response) => {
            priya.debug(url);
            priya.debug(response);
        });
    };

In the example:

In case of the r3m-framework test it shows:

    /user/

    {
        "html": "1",
        "method": null,
        "target": null,
        "script": null,
        "link": null
    }

If we change to request a bit:

    ready(() => {
        request('/user/', {
            "id": 1,
            "method" : "replace",
            "target" : "body h1"
        }, (url, response) => {
            priya.debug(url);
            priya.debug(response);
        });
    };

The result will be:

    <h1 data-mtime="1612646990.702">/user/1/</h1>
    /user/

    {
        "html": "/user/1/",
        "method": "replace",
        "target": "body h1",
        "script": null,
        "link": null
    }

To change the request to a GET instead of a POST:

    ready(() => {
        request('/user/', null, (url, data) => {
            priya.debug(url);
            priya.debug(data);
        });
    });
Last modified: 2021-06-07

© 2021 universeorange.com