Most Popular
Old Way
function createXHRRequest(url) {
if (window.ActiveXObject) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
}
xhr.open("GET", url);
xhr.onreadystatechange = someResponseFunc();
xhr.send(null);
}
function someResponseFunc() {
if (xhr.readyState == 4){
if (xhr.status == 200) {
Do something with xhr.responseText
}
}
}
Prototype
new Ajax.Request(url, {
method: 'get',
parameters: pars,
onComplete: someResponseFunc
});
function someResponseFunc(origRequest) {
Do something with origRequest.responseText;
}
Bonus: Form.serialize('myform')