$.ajax({
url: '/dir/file.php',
type: 'post',
dataType: 'json',
data: {action: 'ftype', btype: btype, urlForPagi: urlForPagi},
success: function(json){
if(typeof json.success !== 'undefined'){
$(document).find('.loadItemsHere').html(json.success);
} else if(typeof json.error !== 'undefined'){
return alert(json.error);
}
},
error: {...}
});
$result[] = array();
$items = $peger->getItems("SELECT * FROM `budget` WHERE `type` = '".$btype."' ORDER BY `id` DESC");
foreach($items as $budget){
$result[] = array(
'id' => $budget['id'],
'type' => $budget['type']
);
}
echo json_encode(['success' => $result], JSON_UNESCAPED_UNICODE);
结果,空又回来了,为什么?
var_dump()如果我这样做,我会看到一切正常:id 和 type
首先我们创建一个数组
$results = array();然后在