Help with 'config.xml' file from phonegap

0

I understand that an application made in phonegap does not accept php, but the application that I use requires it for logins and searches of information in a database. and for a subject about it I understood that the php files were not included to be packaged and create the apk in build.phonegap resulting this way, I would like to know how I create the communication between application in the cell phone and the php files that I left on the server (which are the ones with which it communicates)

As a clue I have in the same publication that I saw that the php was not included for packaging, I said it gave some permission .. but I did not understand that

    
asked by Michelle Vite Pacheco 19.10.2017 в 23:16
source

1 answer

0

Indeed, you can not add PHP in the PhoneGap application. What you could do is have your PHP files on a server (as you seem to indicate you already have) and call them using JavaScript and AJAX.

This could be done easily by doing something like this (use jQuery as an example):

$.ajax({
  url: "https://tudominio.com/tufichero.php",
  method: "POST",
  data: { usuario: valorUser, contrasena: valorPassword },
  success: function(data, textStatus, jqXHR) {
    // operaciones a realizar
  }
});

This procedure is more or less standard and common to any other web application (with or without PhoneGap), but there is still one step you should do: for security the queries to external servers can be cut by Cordova / PhoneGap, > you have to add a white list of domains to which your application can make requests and queries .

To add your domain to the whitelist you must:

  • Install the Whitelist plugin (although you probably already have it because it comes by default in the modern versions of Cordova / PhoneGap)
  • Open the config.xml file
  • Add the domains to which they are allowed access:

    <access origin="http://tudominio.com" />
    
  • Reference and useful links:

    answered by 24.10.2017 / 16:30
    source