The order problem of xmlHttp.onreadystatechange

I have seen many ways to write

    xmlHttp.open("post", "test.php",true); 
    xmlHttp.send(formData); 
    xmlHttp.onreadystatechange =  function(){  }

xmlHttp.onreadystatechange first


    xmlHttp.onreadystatechange =  function(){  }
    xmlHttp.open("post", "test.php",true); 
    xmlHttp.send(formData); 

there is another such

xmlhttp.open ("POST", "Demo", true);
xmlhttp.onreadystatechange=myCallBack;
xmlhttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
xmlhttp.send ("FirstName=Nat&LastName=Dunn");

excuse me,

xmlHttp.open 
xmlHttp.send 
xmlHttp.onreadystatechange =

   
Dec.12,2021

1. Open the request. 2 send the request. 3 request complete.

Menu