PHP에 액세스하여 파일에 쓰는 데 필요한 특정 배열이 있습니다. 나는 또한 배열 정보를 되찾기 위해 PHP를 호출 할 수 있기를 원한다. JSON.strigify를 사용하여 문자열에 배열을 저장하지만 PHP로 서버에 보내는 방법을 알아낼 수 없습니다. 나는 약간의 PHP 경험이 내가 시도 : main.php에파일에 쓸 변수를 php에 보내야합니다.
<script language="javascript">
var COMMENTS_FOR_DISPLAY = new Array('Have fun with this code: Chris');
// Adds a new comment, name pair to the Array feeding textualizer.
function add_comment() {
// Retrieve values and add them to Array.
var new_comment = $('#kwote').val();
var new_name = $('#name').val();
COMMENTS_FOR_DISPLAY.push(new_comment + ': ' + new_name);
// Reset <input> fields.
$('#kwote').val('');
$('#name').val('');
var arrayAsString = JSON.stringify(COMMENTS_FOR_DISPLAY);
}
$(document).ready(function() {
var txt = $('#txtlzr'); // The container in which to render the list
var options = {
duration: 5, // Time (ms) each blurb will remain on screen
rearrangeDuration: 5, // Time a character takes to reach its position
effect: 'random', // Animation effect the characters use to appear
centered: true // Centers the text relative to its container
}
txt.textualizer(COMMENTS_FOR_DISPLAY); // textualize it!
txt.textualizer('start'); // start
});
</script>
은 내가 넣어 :
<?php
$kwoteString = $_GET["arrayAsString"];
echo $kwoteString;
?>
나는 내가 출력을 얻는 경우 볼 에코 사용,하지만 난하지 않았다. 그것은 매우 간단한 수정, 어쩌면 메신저 헤더 또는 뭔가를 main.php를 읽는 내 HTML 문서를 말하는 누락 된 수 ?? 어떤 도움을 주시면 감사하겠습니다!
누락되었습니다. http://api.jquery.com/jQuery.ajax/ –
음 ... PHP 또는 JSON과 어떤 관련이 있습니까? –
아약스는 HTTP 요청을 통해 클라이언트 측과 서버 측 사이에서 통신하는 데 필요합니다 ... – gorelative