Am using AJAX script to have data fetched from database. For example has
- Motorola
- Samsung
- Apple
as company and using AJAX to fetch models of it. Like when apple is selected then it shows apple iPhone 12, iPhone 13, iPhone 14, 14 pro max
Using this older generic script as test basis which is like years old where when a field is selected of company name, then without reloading the page models list come under it.
function createRequestObject(){var e,t=navigator.appName;return e="Microsoft Internet Explorer"==t?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest}
function getRequest(e,t,n,a){elementId=t,loading_layer_in=a,http.open("get",e),http.onreadystatechange=ManipulateRequest,http.send(null)}
function getRequestalert(e){http.open("get",e),http.onreadystatechange=function(){if(4==http.readyState){var e=http.responseText;res=e}},http.send(null)}
function ManipulateRequest(){if(""==e)var e="<FONT><B>Loading please wait.........</B></FONT>";else msg=e;if(document.getElementById(loading_layer_in)&&(document.getElementById(loading_layer_in).style.display="block"),1==http.readyState);else if(4==http.readyState){var t=http.responseText;document.getElementById(elementId)&&(document.getElementById(elementId).innerHTML=t)}}
function hideLoadingLayer(e){var t=e;document.getElementById(t)&&(document.getElementById(t).style.display="none")}
var elementId="",loadingMessage="",loading_layer_in="",http=createRequestObject();
It is working.
What is the new AJAX script in line with times which I can use as against same?