0
두 개의 배열이 있습니다. 1 개가 비어 있고 다른 5 개가 있습니다. 나는 그들을 세고 그것을 보여주고 싶다.Ajax가 잘못된 결과를 반환합니다.
는이 같은 아약스 요청을 보내 : 나는 모두가 내가 5를 이해하지 못할하는 응답을받을 때
function countTrash()
{
$.ajax({
type: "GET",
url: "count_trash_delete.php",
data: "action=1",
success: function(response){
$("#badge3").html(response);
}
});
}
function countRemove()
{
$.ajax({
type: "GET",
url: "count_trash_delete.php",
data: "action=2",
success: function(response){
$("#badge2").html(response);
}
});
}
내 count_trash_delete.php이
if(isset($_GET['action'])) {
$action = 1;
}else{
$action = 2;
}
if($action === 1){
$trash_arr = file_get_contents('trash_bots.json');
$trash_arr = json_decode($trash_arr);
$number_of_trashed = count($trash_arr);
echo $number_of_trashed;
}elseif($action === 2){
$remove_arr = file_get_contents('remove_bots.json');
$remove_arr = json_decode($remove_arr);
if(!empty($remove_arr)){
$number_of_removed = count($remove_arr);
echo $number_of_removed;
}else{
echo 'Empty';
}
}
것 같습니다.
오 :
당신은 아마 값
$_GET['action']
의에$action
을 설정합니다. 고마워. – MHH