Centralizing Ajax
You can centralize the ajax code by keeping all the codes in a single function which will be called from anywhere wherever it is needed to have some Ajax call to server. Note the following function: function commonajaxcall (url, para){ var xmlhttp=new XMLHttpRequest(); xmlhttp.open("GET",url, true); xmlhttp.send(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { if((xmlhttp.response).length >0){ if(para=='onecondtion'){ document.getElementById("formfield").innerHTML=name; showAuthorizedSection(); // call someother function if needed }els...