0

I want to transfer data from PHP page which import data from MySql, so I need to show this data on my mobile app (Cordova), I use javascript.

this is the PHP code which I use:

if($count == 1) {
          echo $name .$points . $gold;
          
      }else {
         echo "Your Login Name or Password is invalid";

      }

and this is the Jquery code:

$.ajax({
 type: 'POST',
 url: 'http://xxxxxx/login.php',
 data: datastring,
 success: function(data) {
  alert(data + 'worked');//     does nothing
 }
});
Samir Junaid
  • 113
  • 1
  • 3
  • 17

1 Answers1

0

I found the answer:

1- add 'json_encode' after 'echo' 2- use this code on Javascript:

<script>
    function reqListener () {
      console.log(this.responseText);
    }
    var oReq = new XMLHttpRequest();
    oReq.onload = function() {
        alert(this.responseText);
    };
    oReq.open("get", "http://localhost/send.php", true);
    oReq.send();
</script>
Samir Junaid
  • 113
  • 1
  • 3
  • 17