ajax-sender

Send AJAX requests easily

Usage no npm install needed!

<script type="module">
  import ajaxSender from 'https://cdn.skypack.dev/ajax-sender';
</script>

README

Ajax Sender (Demo)

Send AJAX requests easily

Doc

  • Installation

Simply import AjaxSender into your HTML.

<script src="https://unpkg.com/ajax-sender@1.2.1/AjaxSender.min.js"></script>	
  • How to use

Create a new AjaxSender object with the URL as the first parameter :

let ajax = new AjaxSender('https://your.url', options);
// OR using await
let data = await new AjaxSender('https://your.url', {
    ...,
    wait: true
}).asPromise().send();
  • Options
{
    method: 'GET',
    data: { ... },
    responseType: 'json',
    wait: false, // Wait before sending the request ?
    headers: { ... },
    progress: response => { ... },
    load: response => { ... },
    error: response => { ... },
    uploadProgress: response => { ... },
    uploadLoad: response => { ... }
}
  • Methods

See the documentation for the method definitions.

  • Example

See this JSFiddle for a working example

Authors