The Slog A development blog by Liam Siira

Echo

About

Echo is a compact library for making Ajax requests, built off of WeideMo's MiniAjax Weighing in at under 100 lines of code, Echo provides a convenient interface for Ajax requests, both GET and POST. It also provides innate JSON parsing where possible. Echo was built in order to be used as a compact and intuitive Ajax library for development on the Atheos IDE, however it's proved so valuable as to become it's own mini library. Echo returns the XMLHttpRequest in order to faciliate aborts, and encourage further customization. Only the URL is required in order to send an Echo; All other options are optional and the type defaults to POST.

Echo is licensed under MIT, 2021

Download on Github

Features

Pleasently Parsed: Echo automatically tries to parse JSON replies.

Crazily Condensed: The minified version is less than ~1K, roughly 500b gzipped.

Easily Extensible: Echo is easily modifyable to meet your needs.

Usage

Argument Required Type
url true string
type false ["POST" || "GET"]
data false object
Argument Required Type
timeout false integer
success false function
failure false function
echo({
    url: "./testXhr.php",                // Destination URL
    type: "POST",                        // Request Type: POST (default) or GET
    data: { name: "WeideMo", age: 26 },  // Data sent to the server
    timeout: 5000,                       // Time in Milliseconds
    settled: function (httpResponseCode, reply) {
        // Function called on success or failure
    },
    success: function (httpResponseCode, reply) {
        // Function called on success
    },
    failure: function (httpResponseCode, reply) {
        // Function called on failure
    }
});

Returns XMLHttpRequest

Back to List