Cordova: Ajax works in browser but not on Android device

Asked

Viewed 430 times

0

I need to make an ajax request using Cordova in visual studio, and ajax through Jquery. When I test through the browser works correctly, but when I test Android it returns error with stauts "0" and no message. What could 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);
    }
});
}

1 answer

0

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.