0

I have an ajax request:

$.ajax({
            url: 'DBConnector.php',
            type: 'GET',
            dataType: 'json',
            success: function(data){
//check if exist
}
});

This is what i return:

echo json_encode(array("data" => $returnValue , "status" => "false"));

How to check if status exist(not to be false but really if it exist)?

Bian Goole
  • 195
  • 2
  • 13

1 Answers1

3

You can try the following:

$.ajax({
    url: 'DBConnector.php',
    type: 'GET',
    dataType: 'json',
    success: function(data)
    {
        if(data.status !== undefined)
        {
            //YOUR CODE HERE
        }
    }
});

It will check if the status exists or not.

mega6382
  • 9,211
  • 17
  • 48
  • 69