Tôi có một trang như sau;Nhận dữ liệu từ mảng 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>
và tệp php ajax.php
để xử lý yêu cầu ajax;
<?php
$array = array(1,2,3,4,5,6);
echo $array;
?>
Nhưng khi tôi nhấp, tôi nhận được A
thay vì mảng [0]. Làm thế nào tôi có thể sửa lỗi này??
Cảm ơn trước ...
Vâng, nó cũng là câu trả lời tôi đang tìm kiếm. Cảm ơn ~ –
Tuyệt vời, cảm ơn bạn! –