vendredi 11 mai 2018

Verify data from PHP file with get method (AJAX)

I want to use an if statement to compare data from a PHP file.

I'm using AJAX to get the data from PHP files and append them to HTML.

This will be an example of code.

PHP_file.php

if ($active == "ready") {
   echo "true";
} else {
   echo "false";
}

AJAX Function

$.get("PHP_file.php", function(data, status){
  if (status == "success"){
    if (data == "true") {
      //do something
    } else{
      //do something else
    };
  }
});

The AJAX function doesn't do what I want. Can I read the data, and compare it, with jQuery?

Aucun commentaire:

Enregistrer un commentaire