Ajax does not return values on mobile device

0

Beauty? It's as follows, I have an ajax method that returns a json, the problem is that this ajax does not run on mobile devices. It always returns me fail, however, on the 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. The fail to return an object but I can not handle or verify the error or the pq does not generate json on the cell.

I generate the url through jquery when you click on the 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=";
    
asked by anonymous 03.10.2017 / 19:45

1 answer

0

The problem is in your URL, the host is set to localhost , and port 8080, as it is running on your mobile the browser will not be able to find the information. You can remove http://localhost:8080 from the url, so it does not try to access by that address, but rather by the relative path.

For example, if the address you entered on the mobile to access the url was http://192.168.0.100/index , setting without http://localhost:8080 it will try to find by http://192.168.0.100/meusite/api/findAllContatoFaturasJson.do...

    
03.10.2017 / 20:23