1
データベースからデータを取得しているAjaxリクエストがあります。具体的には2つのカラム、company_idとpeople_id、 jsonの結果から結果をテストする必要があります。特定のpeople_idが存在するかどうかを確認する必要があります。その結果、ここで返されたjson結果をテストするには?
は私のAjaxリクエスト
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() {
}
});
私は成功関数の中で、この次のコードを実行することができると思ったが、それはまたここ
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.');
}
仕事didntのが私の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));
}
}
私は私のコードの書式設定を固定するためのif文 –
おかげで入れするかについてあまりわからない、私はそれは恐ろしい –