{"id":13565471,"url":"https://github.com/anonyco/SuperSimpleExtensibleSmallXMLHttpRequestWrapper","last_synced_at":"2025-04-03T22:31:29.528Z","repository":{"id":66108220,"uuid":"112889465","full_name":"anonyco/SuperSimpleExtensibleSmallXMLHttpRequestWrapper","owner":"anonyco","description":"The ULTIMATE 338-byte super small, simple, light, fast, XMLHttpRequest wrapper.","archived":false,"fork":false,"pushed_at":"2020-01-16T02:03:39.000Z","size":10,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T22:28:45.278Z","etag":null,"topics":["1kb","drop-in-script","easy-to-use","http","javascript","javascript-library","js","js-library","library","no-framework","no-jquery","vanilla-js","vanillajs","xhr","xmlhttprequest","xmlhttprequest-wrapper"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anonyco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-12-03T00:53:03.000Z","updated_at":"2023-11-06T23:14:17.000Z","dependencies_parsed_at":"2023-02-23T20:00:27.823Z","dependency_job_id":null,"html_url":"https://github.com/anonyco/SuperSimpleExtensibleSmallXMLHttpRequestWrapper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anonyco%2FSuperSimpleExtensibleSmallXMLHttpRequestWrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anonyco%2FSuperSimpleExtensibleSmallXMLHttpRequestWrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anonyco%2FSuperSimpleExtensibleSmallXMLHttpRequestWrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anonyco%2FSuperSimpleExtensibleSmallXMLHttpRequestWrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anonyco","download_url":"https://codeload.github.com/anonyco/SuperSimpleExtensibleSmallXMLHttpRequestWrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247090242,"owners_count":20881935,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["1kb","drop-in-script","easy-to-use","http","javascript","javascript-library","js","js-library","library","no-framework","no-jquery","vanilla-js","vanillajs","xhr","xmlhttprequest","xmlhttprequest-wrapper"],"created_at":"2024-08-01T13:01:47.630Z","updated_at":"2025-04-03T22:31:28.411Z","avatar_url":"https://github.com/anonyco.png","language":"JavaScript","readme":"# SuperSimpleExtensibleSmallXMLHttpRequestWrapper\nThe ULTIMATE super small, simple, light, fast, XMLHttpRequest wrapper. The documentation is as follows:\n\n### How To use / Install\n\n#### From A Dropbox Server\n\nJust simply put this into your `\u003chead\u003e` (or at least somewhere before the code that uses it).\n```Html\n\u003cscript src=\"https://dl.dropboxusercontent.com/s/y9muahvy3m8bsp6/superxhr.min.js?dl=0\"\u003e\u003c/script\u003e\n```\n\n#### From A Local Copy\nIf the drop box link broke or you simply don't want to use dropbox, then you can download superxhr.min.js, place it in the same directory (folder) as your HTML file, and put this into your `\u003chead\u003e` (or at least somewhere before the code that uses it).\n```Html\n\u003cscript src=\"superxhr.min.js\"\u003e\u003c/script\u003e\n```\n\nThen, Super XHR JS will set `window.HTTP` to the XHRing function it creates.\n\n### Documentation\n\nTo use Super XHR JS, simply pass an object to `window.HTTP` with all the properties going to the XMLHttpRequest object, and some special properties listed below effecting the behavior.\n\n```Javascript\nvar XHRobj = HTTP({\n    URL: \"/path/to/file\",\t// the relative URL to the file\n\tUSER: \"username\",\t\t// the username sent to the server when performing the request.\n\tPASSWORD: \"password\",\t// the username sent to the server when performing the request.\n    METHOD: \"GET\",\t\t\t// Any valid HTTP method\n    POST: \"post data goes here if METHOD is POST\",\t// Post data (if the selected METHOD supports post data)\n    SYNC: false,\t\t\t// pass true for synchronous transfer (which is not reccomended)\n\t// Super XHR JS also supports all standard and future properties of requests:\n\tonreadystatechange: function(evt){\n\t\tvar readyState = evt.target.readyState;\n\t\t// ... \n\t},\n\ttimeout: 2500, // Timeout after 2.5 seconds\n\tsetRequestHeader: [[\"Content-Type\", \"text/html\"], ['Range', 'bytes=100-200']]\n\t// There are many more methods not listed here to keep the above code nice and short. See\n\t// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/ for a complete list.\n});\n```\n\nThen, after you have sent the request once, you can keep on reusing it with the awesome `XHRobj.resend(new_url, new_post_data)` function to keep on reusing the same setup like so:\n\n```Javascript\nXHRobj.resend(\"/new/path/to/file\", \"new post data\");\n```\nNext, looking at the above example code, notice setRequestHeader. The format for this may look rather foreign, but I assure you it is incredibly simple. Basicly. when you set a property of the XMLHttpRequest object that is a function, instead of the new value being set there, the new value is instead used as an array of arrays whereby each sub array is `Function.prototype.apply`ed to the XMLHttpRequest object. So, from the example above:\n\n\n```Javascript\nvar XHRobj = HTTP({\n\t// ...\n\tsetRequestHeader: [[\"Content-Type\", \"text/html\"], ['Range', 'bytes=100-200'], [\"Foo\", \"Bar\"]]\n\t// ...\n});\n```\n\nThe vanilla javascript equivelent of this is as listed below:\n\n\n```Javascript\nvar k = new XMLHttpRequest();\nk.setRequestHeader(\"Content-Type\", \"text/html\");\nk.setRequestHeader('Range', 'bytes=100-200');\nk.setRequestHeader(\"Foo\", \"Bar\");\n```\n\nLikewise, this setup can be applied to any function on the XMLHttpRequest interface like so:\n\n```Javascript\nvar XHRobj = HTTP({\n\t// ...\n\toverrideMimeType: [[\"text/html\"]],\n\taddEventListener: [\n\t\t[\"load\", function(x){\n\t\t\t// ...\n\t\t}],\n\t\t[\"error\", function(x){\n\t\t\t// ...\n\t\t}]\n\t]\n\t// ...\n});\n```\n\n\n\n\n\n\n\n\n\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanonyco%2FSuperSimpleExtensibleSmallXMLHttpRequestWrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanonyco%2FSuperSimpleExtensibleSmallXMLHttpRequestWrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanonyco%2FSuperSimpleExtensibleSmallXMLHttpRequestWrapper/lists"}