simple AJAX

this is the AJAX implementation i use:

function jfetch(url,t,o) {
var req = jfetch.xhr();"GET",url,true);
req.onreadystatechange = function() {
if(req.readyState == 4){
var rsp = req.responseText;
if(t.constructor == Function) return t.apply(o,[rsp]);
t = document.getElementById(t);
t[t.value ==undefined ? 'innerHTML': 'value'] = rsp;
req = null;
jfetch.xhr =
? function(){ return new ActiveXObject("Microsoft.XMLHTTP"); }
: function(){ return new XMLHttpRequest()};
it's short, it only checks for the transport (ActiveX or XHR) once, and it takes either an element id or a call back function. and, i can understand it.


Popular posts from this blog

python interval tree

filtering paired end reads (high throughput sequencing)

my thoughts on golang