2013-10-01 110 views
0
<!doctype html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
    <script type="text/javascript" src="./js/jquery.js"></script> 


</head> 
<body> 
    <div class="vpic"><img src="" width="800" /></div> 
    <div> 
     <div style="float:left; margin-right:10px; cursor:pointer" class="cpic"><img src="" width="200" /></div> 
     <div style="float:left; margin-right:10px; cursor:pointer" class="cpic"><img src="" width="200" /></div> 
     <div style="float:left; margin-right:10px; cursor:pointer" class="cpic"><img src="" width="200" /></div> 
    </div> 

    <script type="text/javascript"> 
     $(document).ready(function(){ 
     console.log("connected"); 
     $.post("get.php",{},function(shilpa,status){ 

       alert("status"+status); 
       },"json"); 

     }); 



    </script> 

</body> 
</html> 

//get.php交互與服務器和客戶端的JSON

<!DOCTYPE html> 
<html> 
<head> 
<link rel="stylesheet" href="css/style.css"/> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<script src="./js/jquery.js"></script> 
var user= <?php echo json_encode(array("data"=>array(
    "father" => array(1,2,3), 
    "mother" => array(1,2,3), 
    "kid" => array(1,2,3) 
))); ?> 
</script> 
<title>try</title> 
</head> 

我新的JSON我想打印這是從get.php但沒有未來的JSON數據是回來的時候我正在寫這個代碼。

+0

你從'get.php'文件打印JSON? – Darren

+0

你能告訴我們你的'get.php'源代碼是否是'echo json_encode($ data);'或者什麼? – Chokchai

回答

0

get.php應該只是打印JSON數據:

<?php 
    header('Content-type: application/json'); 
    echo json_encode(array("data" => array(
     "father" => array(1,2,3), 
     "mother" => array(1,2,3), 
     "kid" => array(1,2,3) 
    ))); 
?>