1.2.2 • Published 4 years ago

@megagames.me/fetchfile v1.2.2

Weekly downloads
-
License
GPL-2.0-only
Repository
-
Last release
4 years ago

Fetchfile.js

version (v1.2.2) earliest stable version (v1.2.2) version in dev (None) hits per month

The simplest way to use Ajax for beginners.

About

We all love Ajax, right? But, JavaScript just messed it up. You have to use the most annoying syntax ever: XMLHttpRequest, or XHR. It is an absolute pain to write it out. But, I decided to create a library that can fit XHR into one line of JS code. It is called Fetchfile.js.

Comparison

XHR

//XMLHttpRequest
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
	if (this.readyState == 4 && this.status == 200) {
		document.getElementById("ajaxoutput").innerHTML = this.responseText;
	}
};
xhttp.open("GET", "path/to/file.txt", true);
xhttp.send();

Fetchfile.js

Fetchfile("path/to/file.txt", false, "text", "#ajaxoutput");

They do the exact same thing, but one is by far the easiest to write.

Installation

npm

To install Fetchfile.js on npm, run the command npm i @megagames-me/Fetchfile.js.

Important: Fetchfile.js requires jQuery 3.4.1 as a dependency.

CDN

To import Fetchfile.js into your HTML project, use this code.

<script type="text/javascript" src="//code.jquery.com/jquery-3.4.1.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/gh/megagames-me/Fetchfile.js@1.2.2/fetchfile.min.js"></script>

Note: If you want to, you can use the beta version here:

<script type="text/javascript" src="//gitcdn.link/cdn/megagames-me/Fetchfile.js/f6c5f716e3d84d9b3ef230a67322ed827509a76e/beta/fetchfile.js"></script>

This is not recommended, as it uses the latest beta version. This, however, is NOT a release! It is just the file straight from GitHub raw. This may change, so this is not recommended for production usage.

Parameters

Fetchfile(filepath, secure, outputType, whitespaceType, returnId, saveto, callback);
1.2.2

4 years ago

1.2.0

4 years ago

1.2.1

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago