相关疑难解决方法(0)

从php数组中获取数据 - AJAX - jQuery

我有一个页面如下;

<head>
<script type="text/javascript" src="jquery-1.6.1.js"></script>
<script type="text/javascript">
$(document).ready( function() {
$('#prev').click(function() {
  $.ajax({
  type: 'POST',
  url: 'ajax.php',
  data: 'id=testdata',
  cache: false,
  success: function(result) {
    $('#content1').html(result[0]);
  },
  });
});
});
</script>
</head>
<body>
<table>
<tr>
<td id="prev">prev</td>
<td id="content1">X</td>
<td id="next">next</td>
</tr>
</table>
</body>
Run Code Online (Sandbox Code Playgroud)

和一个ajax.php处理ajax请求的php文件;

<?php
$array = array(1,2,3,4,5,6);
echo $array;
?>
Run Code Online (Sandbox Code Playgroud)

但是当我点击时,我得到的A不是数组[0].我怎样才能解决这个问题??

提前致谢...

javascript jquery json

23
推荐指数
3
解决办法
15万
查看次数

标签 统计

javascript ×1

jquery ×1

json ×1