-
Notifications
You must be signed in to change notification settings - Fork 0
/
simpleAjax.min.js
1 lines (1 loc) · 937 Bytes
/
simpleAjax.min.js
1
"use strict";function simpleAJAX(){this.http=new XMLHttpRequest}simpleAJAX.prototype.get=function(t,s){var e=this;this.http.open("GET",t,!0),this.http.onload=function(){200===e.http.status?s(null,e.http.responseText):s("Error: "+e.http.status)},this.http.send()},simpleAJAX.prototype.post=function(t,s,e){var p=this;this.http.open("POST",t,!0),this.http.setRequestHeader("Content-type","application/json"),this.http.onload=function(){e(null,p.http.responseText)},this.http.send(JSON.stringify(s))},simpleAJAX.prototype.put=function(t,s,e){var p=this;this.http.open("PUT",t,!0),this.http.setRequestHeader("Content-type","application/json"),this.http.onload=function(){e(null,p.http.responseText)},this.http.send(JSON.stringify(s))},simpleAJAX.prototype.delete=function(t,s){var e=this;this.http.open("DELETE",t,!0),this.http.onload=function(){200===e.http.status?s(null,"Resource Deleted!"):s("Error: "+e.http.status)},this.http.send()};