1 function submit(url, params) {
2 var xulrequest=new XMLHttpRequest();
3 xulrequest.open("POST",url,false);
4 xulrequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");
5 alert(url);
6 alert(params);
7 xulrequest.send(params);
8 var headers = xulrequest.getAllResponseHeaders();
9 var response = xulrequest.responseText;
10 alert(xulrequest.status+' '+xulrequest.statusText+', '+headers+'\n'+response);
11 return response;
12 }
13
14 function replace(response, oldId, newId) {
15 var oldElement = document.getElementById(oldId);
16 var dom = (new DOMParser()).parseFromString(response, "text/xml");
17 var newElement = dom.getElementById(newId);
18 document.replaceChild(newElement, oldElement);
19 }