Skip to main content
1 of 4
Ruchika
  • 103
  • 3

Better Ajax script to load data from table

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 i phone 12, i phone 13, i phone 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();

and is working too Wondering whats the new ajax script in line with times which i can use as against same.

Thanks

Ruchika
  • 103
  • 3