大家好,是這樣的,我現在有一個從mysql抓出的資料
我想把它存成陣列,透過ajax傳到另外一個php頁面去做資料處理再回傳回來。
不知為何一直出現錯誤,接收不到值,想請問一下各位高手這種問題是出在哪裡~
請大家撥空看一下我的程式碼感謝~~
foreach ($nut as $key => $value) {
	$sth = $conn->prepare($value);
	$sth->execute();
	for($p=0; $row = $sth->fetch(); $p++){
			if ($row['name']!="") {
				$aio[] = $row['name'];
						}}//for end
                        }
foreach (array_unique($aio) as $key => $value) {
			echo $value;
			$content = json_encode($value);
			$jsondata = "data(".$content.");";
			 print_r($jsondata);}
<div id="adphp"></div>  //存放回傳的地方                      
<script>
			 $(document).ready(function (){
				  $.ajax({
				    url: 'ad.php',
				    method: 'POST',
				    dataType: 'json',
				    data: 'active=json',
				    error: function(xhr) {
				      alert('Ajax request 發生錯誤');
				    },
				    success: function(response) {
				        $('#adphp').html(response);
				        alert('Ajax request');
				    }
				  });
				});
		</script>
//接收頁面 ad.php
<?php 
	$data=$_POST['data'];
	echo $data;
 ?>