快捷搜索:   服务器  安全  linux 安全  MYSQL  dedecms

PHP中JSON的应用(2)

<?php  
  • $arr = array(  
  •     'name' => '陈毅鑫',  
  •     'nick' => '深空',  
  •     'contact' => array(  
  •         'email' => 'shenkong at qq dot com',  
  •         'website' => 'http://www.chinaz.com',  
  •     )  
  • );  
  • $json_string = json_encode($arr);  
  • echo "getProfile($json_string)";  
  • ?> 
  •  

    很显然,当index.html调用profile.php时,JSON字符串生成,并作为参数传入getProfile,然后将昵称插入到div中,这样一次跨域数据交互就完成了,是不是特别简单。既然JSON这么简单易用而且好用,还等什么呢?

    顶(0)
    踩(0)

    您可能还会对下面的文章感兴趣:

    最新评论