但是,警告框显示字符串类型。
那么我怎样才能获得第一个carsArr变量数组?谢谢!
<?php
$car1=array("Saab","Volvo","BMW");
$car2=array("123","234","345");
$cars = array($car1, $car2);
?>
<script type="text/javascript">
$(function () {
var cars =jQuery.parseJSON('<?php echo json_encode($cars); ?>');
var carsArr =jQuery.makeArray(cars);
var aCar = carsArr[0];
alert(typeof(aCar));
});
</script>
答案 0 :(得分:1)
看起来你正在做PHP中的变量赋值javascript
更改$cars = array(car1, car2);
至$cars = array($car1, $car2);