Phonegap Ajax Error

Asked

Viewed 139 times

0

I’m making an application to send and receive records in real time when I tested the application in the browser it was working normally, but when I converted it apk and installed it on my mobile phone it was giving error in ajax, can anyone help me?

$.ajax({
    url: "sys/fetchdata.php",
    type: "POST",
    dataType: "json",
    data: { tipo: "insere_evento",
            tipo_evento: tipo_evento,
            id_user:session_user,
            lat: lat,
            lon: lon
          },success: function(retorno){
             if(retorno.status == "ok"){
                alert("Evento registrado com sucesso");
             }else{
                alert("Ocorreu um erro, tente novamente mais tarde");
             }
          },error: function(e){
                alert("Falha ao conectar ao servidor, tente novamente mais tarde");
            }
        });
  • If you are using Cordova 4.1+ and tried to install the App on Android, it may be a problem with Whitelist. Take a look here: https://www.npmjs.com/package/cordova-plugin-whitelist

  • thank you, it was exactly Whitelist problem, I managed to solve

  • What error occurs? Gives a console.log or Alert in ajax return xhr.

  • so my friend, the error was in the version I was using jquery, I was using the pc version until I had the idea to switch to jquery mobile and it worked, it was stupid my own, but thanks for the help

  • By default, Phonegap has a "block" to access web pages by the app. But for those who need this access, he has in his own documentation a guide explaining how to solve it. Here is the link: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-whitelist/#supported-Cordova-Platforms Run the following commands in your terminal, in your application directory: $ Cordova plugin add Cordova-plugin-Whitelist $ Cordova prepare (If it’s windows, you don’t need $) And add the following line to your config.xml: <allow-navigation href="*" /> This line, b

No answers

Browser other questions tagged

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