Skip to content

Instantly share code, notes, and snippets.

@idettman
Last active August 29, 2015 14:01
Show Gist options
  • Save idettman/66d27e23757426227134 to your computer and use it in GitHub Desktop.
Save idettman/66d27e23757426227134 to your computer and use it in GitHub Desktop.
Sans jQuery
document.addEventListener("DOMContentLoaded", start);
Array.prototype.slice.call(document.getElementsByTagName("p"));
function Each(obj, fn) {
if (obj.length) for (var i = 0, ol = obj.length, v = obj[0]; i < ol && fn(v, i) !== false; v = obj[++i]);
else for (var p in obj) if (fn(obj[p], p) === false) break;
};
document.getElementById("clickme").addEventListener("click", function(e) {
console.log("you clicked " + e.target);
e.preventDefault();
});
var r = new XMLHttpRequest();
r.open("POST", "webservice", true);
r.onreadystatechange = function () {
if (r.readyState != 4 || r.status != 200) return;
console.log(r.responseText);
};
r.send("a=1&b=2&c=3");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment