0
I am making an Ajax request for a PHP page that returns several data in XML. If I make a simple code recovery by opening the PHP page directly, sure, however I am making the request for another page that calls the data from another PHP via Ajax with Jquery.
My job today:
$.ajax({
url: "consultaPlaca.php",
type: "get",
data: {placa : 'XXX9999'},
success: function (retorno) {
teste = retorno;
console.log(retorno.Placa.text());
localStorage.setItem('placa', $("placa").text());
localStorage.setItem('renavam', $("renavam").text());
localStorage.setItem('tipo', $("tipo").text());
localStorage.setItem('marca', $("marca").text());
localStorage.setItem('modelo', $("modelo").text());
localStorage.setItem('importado', $("importado").text());
localStorage.setItem('combustivel', $("combustivel").text());
localStorage.setItem('cor', $("cor").text());
localStorage.setItem('categoria', $("categoria").text());
localStorage.setItem('roubofurto', $("roubofurto").text());
localStorage.setItem('roubofurtocodigo', $("roubofurto roubofurtocodigo").text());
localStorage.setItem('roubofurtodescricao', $("roubofurto roubofurtodescricao").text());
localStorage.setItem('roubofurtocomplemento', $("roubofurto roubofurtocomplemento").text());
localStorage.setItem('anofabricacao', $("anofabricacao").text());
localStorage.setItem('anolicenciamento', $("anolicenciamento").text());
localStorage.setItem('anomodelo', $("anomodelo").text());
localStorage.setItem('ipva', $("ipva").text());
localStorage.setItem('inspecaoveicular', $("inspecaoveicular").text());
localStorage.setItem('multascetesb', $("multascetesb").text());
localStorage.setItem('multasder', $("multasder").text());
localStorage.setItem('multasdersa', $("multasdersa").text());
localStorage.setItem('multasdetran', $("multasdetran").text());
localStorage.setItem('multasmunicipais', $("multasmunicipais").text());
localStorage.setItem('multasprf', $("multasprf").text());
localStorage.setItem('observacoes', $("observacoes").text());
localStorage.setItem('registroguincho', $("registroguincho").text());
localStorage.setItem('restricaoadministrativa', $("restricaoadministrativa").text());
localStorage.setItem('restricaofinanceira', $("restricaofinanceira").text());
localStorage.setItem('restricaojudiciaria', $("restricaojudiciaria").text());
localStorage.setItem('restricaotributaria', $("restricaotributaria").text());
localStorage.setItem('totalmultas', $("totalmultas").text());
localStorage.setItem('totalimpostos', $("totalimpostos").text());
localStorage.setItem('total', $("total").text());
localStorage.setItem('datahora', $("datahora").text());
localStorage.setItem('status', $("transacao status").text());
localStorage.setItem('codigostatus', $("transacao codigostatus").text());
localStorage.setItem('codigostatusdescricao', $("transacao codigostatusdescricao").text());
}
});
This works if I play directly on the console of the page that makes the query, however via get from AJAX, comes the data, but I can’t catch them doing just that: retorno.placa.text();
Edith the question and put the code
PHP
.– NoobSaibot
You can show an excerpt from this
xml
?– Sergio
I think you should wear
$(retorno).find("placa").text()
and so on. In this way$("placa").text()
jQuery does not know the element$("placa")
.– Sam
If the data comes in
xml
it is necessary to specifydataType: "xml"
on request or make parse of the response before using it– Isac