Skip to content

MSM9731/xhr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

Ajax request function

What is the xhr?

This is a function to make ajax requests faster and easier

How to use:

First, add the xhr.js from your Javascript folder to the project:

<script src="./js/xhr.js" type="text/javascript"></script>

Then, you can send an Ajax request and manage the response as follows:

xhr({
  url: URL                                (requaired),
  method: 'GET | POST'                    (optional, POST by default),
  async: true | false                     (optional, true by default),
  data: FormData | Json                   (optional, empty string by default),
  contentType: String                     (optional, 'application/x-www-form-urlencoded; charset=UTF-8' by default),
  accept: String                          (optional, '*/*' by default),
  XRequestedWith: String                  (optional, 'XMLHttpRequest' by default),
  headers: Json                           (optional, null by default),
  success: callback(response)             (optional, empty function by default),
  fail: callback(response)                (optional, empty function by default),
  always: callback(response)              (optional, empty function by default),
  readystatechange: callback(response)    (optional, empty function by default)
})

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published