function post(url, cb, data) {
var req = new XMLHttpRequest;
req.open('POST', url);
// req.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
req.onload = function () {
try {
req.responseJSON = JSON.parse(req.responseText);
} catch (e) {}
cb.call(this, req);
};
if (isFormElement(data)) { // data instanceof HTMLFormElement
data = new FormData(data);
} else if (false == data instanceof FormData) {
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
if (isPlainObject(data)) { // typeof data=='object'
data = buildQuery(data); // var temp=[];for(var i in data) temp.push(encodeURIComponent(i)+'='+encodeURIComponent(data[i]));data=temp.join('&');
}
}
req.send(data);
}