net.put => net.request('PUT'; improved usability for "Save" buttons
This commit is contained in:
parent
e7afb4f19e
commit
eccc98b83b
4 changed files with 28 additions and 31 deletions
|
|
@ -9,22 +9,9 @@ define(function(require, exports, module) {
|
|||
"use strict";
|
||||
var dom = require("./dom");
|
||||
|
||||
exports.get = function (url, callback) {
|
||||
exports.request = function (verb, url, data, callback) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
xhr.onreadystatechange = function () {
|
||||
//Do not explicitly handle errors, those should be
|
||||
//visible via console output in the browser.
|
||||
if (xhr.readyState === 4) {
|
||||
callback(xhr.responseText);
|
||||
}
|
||||
};
|
||||
xhr.send(null);
|
||||
};
|
||||
|
||||
exports.put = function (url, data, callback) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('PUT', url, true);
|
||||
xhr.open(verb, url, true);
|
||||
xhr.onreadystatechange = function () {
|
||||
//Do not explicitly handle errors, those should be
|
||||
//visible via console output in the browser.
|
||||
|
|
@ -35,6 +22,10 @@ exports.put = function (url, data, callback) {
|
|||
xhr.send(data);
|
||||
};
|
||||
|
||||
exports.get = function (url, callback) {
|
||||
this.request('GET', url, null, callback);
|
||||
};
|
||||
|
||||
exports.loadScript = function(path, callback) {
|
||||
var head = dom.getDocumentHead();
|
||||
var s = document.createElement('script');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue