Ich habe eine Ajax Anfrage, die Daten aus meiner Datenbank, speziell zwei Spalten davon, company_id und people_id, Ich muss das Ergebnis, das aus dem Json-Ergebnis kommt, ich muss prüfen, ob eine bestimmte people_id in der existiert ErgebnisSo testen Sie das zurückgegebene JSON-Ergebnis?
hier ist meine Ajax-Request
Ext.Ajax.request({
url: 'system/index.php',
method: 'POST',
params: {
class: 'CompanyPeople',
method: 'secget',
data: Ext.encode({
people_id: Ext.getCmp('peopleGrid').selectedRecord.data.people_id
})
},
success: function (response) {
},
failure: function() {
}
});
ich dachte, ich in der Erfolgsfunktion dieses folgenden Code tun konnte, aber es hat nicht
if (data == 0) {
Ext.MessageBox.alert('Status', 'Person is not attached to anything bud!.');
}
else {
Ext.MessageBox.alert('Status', 'Person already attached to another company.');
}
arbeiten auch hier ist meine php
class CompanyPeople extends Connect {
function __construct() {
parent::__construct();
}
public function secget($vars) {
$sql = "SELECT * FROM CompanyPeople where people_id={$vars->data->people_id}";
$data = array();
$total = 0;
if ($result = $vars->db->query($sql)) {
while ($row = $result->fetch_assoc()) {
$data[] = array("people_id" => intval($row["people_id"]));
$total++;
}
$result->free();
}
echo json_encode(array("success" => true, "total" => $total, "topics" => $data));
}
}
Ich bin nicht ganz sicher über das, was für die Festsetzung meiner Code-Formatierung in dem if-Anweisung –
dank zu setzen, ich weiß, es war schrecklich –