0
beauty? It is the following, I have an ajax method that returns a json, the problem is that this ajax does not run on mobile devices. Always return me fail, however, on pc, everything happens normally.
jQuery.ajax({
url: url,
method: "get",
dataType: "json"
}).done(function(retorno){
for(var i = 0; i < retorno.myArrayList.length; i++) {
if(retorno.myArrayList[i].map.status == 1) {
retorno.myArrayList[i].map.status = "Aberta"
} else if(retorno.myArrayList[i].map.status == 2) {
retorno.myArrayList[i].map.status = "Paga"
} else {
retorno.myArrayList[i].map.status = "Cancelada"
}
linha += '<tr>';
linha += '<td>' + retorno.myArrayList[i].map.nomePaciente + '</td>';
linha += '<td><a href="'+ retorno.myArrayList[i].map.idFatura + '" data-fatura="' + retorno.myArrayList[i].map.idFatura + '">' + retorno.myArrayList[i].map.nomeFatura + '</a></td>';
linha += '<td>' + retorno.myArrayList[i].map.valorFatura.toLocaleString('pt-br',{style: 'currency', currency: 'BRL'}) + '</td>';
linha += '<td>' + retorno.myArrayList[i].map.vencimento + '</td>';
linha += '<td>' + retorno.myArrayList[i].map.dataPagamento + '</td>';
linha += '<td>' + retorno.myArrayList[i].map.status + '</td>';
linha += '</tr>';
totalRec += retorno.myArrayList[i].map.valorFatura;
}
table.append(linha);
retorno = "";
$(".tr-modal").text(totalRec.toLocaleString('pt-br',{style: 'currency', currency: 'BRL'}))
$(".modalConta-back").fadeIn();
$(".modalConta").css("transform", "translateX(0)");
}).fail(function(erro){
alert(erro);
});
The request always fails but on the pc everything happens normally. fail even returns an object but I can’t manipulate or verify the error or pq doesn’t generate json mobile.
I URL through jquery when clicking on table row.
var dia = ($(this).find("td:nth-child(1)").text() < 10) ? "0" + $(this).find("td:nth-child(1)").text() : $(this).find("td:nth-child(1)").text();
var mes = $("#month").val();
var ano = $("#year").val();
var url = http://localhost:8080/meusite/api/findAllContatoFaturasJson.do?day="+ dia + "&month=" + mes + "&year=" + ano +"&tipo=2&p1=0&dentistaId=&vendedorId=&formaPagamentoId=";
"does not generate json on mobile." ? Have you tested
alert(JSON.stringify(erro));
? Or create adiv
to log like this and uselogDiv.textContent = JSON.stringify(erro);
– Sergio
Is fairly vague, on mobile is running via HTTP or is it a webView Asset? What is the fail error message? Give details.
– Guilherme Nascimento
Is the URL the same in both environments? Mobile can reach the URL?
– Oralista de Sistemas
Yes, the url is formed via javascript. I attached the tbm code to see. Then, when clicking on the line, the url is generated, attached to the ajax and returned to json. Or it should be like this on cellular tbm. By json stringy recommended by Sergio, gives the following message: {"readyState":0,"status":0,"statusText":"error"}
– user60485
localhost will not work on mobile, you will need to put the IP of your computer so that it can locate the data
– Denis Rudnei de Souza
or place the url without the
http://localhost:8080
– Denis Rudnei de Souza
Daniel, exactly that. I inserted the ip of my device and it worked right on the mobile. valeu ae!!!!
– user60485