Cordova: Ajax works in browser but not Android device [duplicate]

0

I need to make an ajax request using Cordova in visual studio, and ajax through JQuery. When I do the test through the browser works correctly, but when I do Android test it returns error with "0" stats and no message. What could it be?

function teste_login(cpf, password) {
var cpfSenha = { cpf: cpf, senha: password };
var retornoObj;

cpfSenha = JSON.stringify(cpfSenha);

$.ajax({
    url: 'http://url-arquivo.php',
    type: 'POST',
    crossDomain: true,
    data: cpfSenha,
    dataType: 'html',
    success: function (msgJson) {

       retornoObj = JSON.parse(msgJson.replace(/ +(?![\. }])/g, ''));

        if (retornoObj.sucesso == true) {             
            window.location.href = "principal.html";
        }
    },
    error: function (xhr, thrownError) {
        alert(xhr.status);
        alert(xhr.responseText);
        alert(thrownError);
    }
});
}
    
asked by anonymous 05.12.2017 / 17:20

1 answer

0

This may vary depending on the version of HTML that is on the device, try also to see if the permissions required by the Android application to do this type of procedure an external request) are added.

    
13.12.2017 / 20:57