I'm not getting the answer to the ajax request. The code does not confirm whether it is working or not.
<script type="text/javascript">
function iniciarAjax(){
var ajax = false;
if(window.XMLHttpRequest){
ajax = new XMLHttpRequest();
}else if(window.ActiveXObject){
try{
ajax = new ActiveXObject("Msxml2.XMLHttpRequest");
}
catch(e){
try{
ajax = new ActiveXObject("Microsoft.XMLHttpRequest");
}catch(ex){
ajax = false;
}
}
}
return ajax;
}
var conectarServidor = iniciarAjax();
if(conectarServidor){
conectarServidor.onreadystatechange = function(){
if(conectarServidor.readyState == 4){
if(conectarServidor.status == 200{
alert("Tudo certo")
}
else{
alert("Problema ocorreu")
}
}
conectarServidor.open("GET","http://localhost/locadora/cadastro.php");
conectarServidor.send();
}
}
</script>