: 인 test.html에JQuery와 액세스 PHP jason_encoded 배열
<?php
array_push($stack, "BLABLA");
array_push($stack, "BLABLA2");
echo json_encode($stack);
?>
:
<script type="text/javascript">
$(document).ready(function(){
$.post(
'test.php', // location of your php script
{}, // any data you want to send to the script
function(data){ // a function to deal with the returned information
$('#mydiv').html(data[0]).show();
}, "json");
});
</script>
<div id="mydiv"></div>
제가 몇몇 검사를 완료하고 그 데이터 [0]이 아니라고 보인다 내가 PHP에서 밀어 첫 번째 요소에 액세스하는 올바른 방법. 그러면 어떻게해야합니까?
배열이'$ stack'이라고 알고 계셨습니까?'$ array'라는 변수에'json_encode()'를 사용하고 계십니까? – JakeParis
당신은 서버에서받는 json을 게시 할 수 있습니까 – dakait
솔직히 그것을 찾아내는 방법을 모른다! 아주 미안해. – Kam