我正在尝试提取 json 的值,但是当我返回它时,我得到了一个对象对象。我在解码时做错了什么?这是php中的解码代码
<?php $contenido=file_get_contents("https://www.deperu.com/api/rest/cotizaciondolar.json");
$info = json_decode($contenido,true);
$cadena=array(
0=>$info['cotizacion'],
);
echo json_encode($cadena);
?>
这是功能代码
<script>
$(function() {
$("#btnbuscar").on('click',function(){
var direccion='servicio.php';
$.ajax({
type:'get',
url:direccion,
success:function(datos){
var campo=eval(datos);
alert(datos[0]);
}
});
return false;
});
});
</script>
当年话下
largeQ
ABOUTYOU
哆啦的时光机