Skip to content

Instantly share code, notes, and snippets.

@Aymkdn
Created July 12, 2016 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aymkdn/2f15f50bbe696b2441683f52f2230ad2 to your computer and use it in GitHub Desktop.
Save Aymkdn/2f15f50bbe696b2441683f52f2230ad2 to your computer and use it in GitHub Desktop.
Tiny HTTP Get/Post
/*
m: method ("get", "post")
u: url
c: callback (with 'xhr' as a parameter)
a: async (true / default) or sync (false)
d: post_data (the data to post)
*/
function tiny_http(m,u,c,a,d){var _xhr=new(this.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP");with(_xhr)onreadystatechange=function(){4^readyState||c(_xhr)},open(m,u,a),"post"===m.toLowerCase()?setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"):"",send(d)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment