首页 > Web开发 > 详细

PHP响应头

时间:2017-11-11 19:36:24      阅读:244      评论:0      收藏:0      [点我收藏+]

(1)text/plain

       服务器端:

              header(‘Content-Type: text/plain‘);

              echo ‘succ‘;

       客户端:

              if(xhr.responseText===‘succ‘){ ... }

  (2)text/html

       服务器端:

              header(‘Content-Type: text/html‘);

              echo "<tr><td>$data</td></tr>";

       客户端:

              tbody.innerHTML = xhr.responseText

  (3)application/javascript

       服务器端:

              header(‘Content-Type: application/javascript‘);

              echo "alert($data); f1(); f2($data)";

       客户端:

              eval( xhr.responseText )

  (4)application/xml

       服务器端:

              header(‘Content-Type: application/xml‘);

              echo "<bookList><book>$b</book></bookList>";

       客户端:

              var document = xhr.responseXML

  (5)application/json

       服务器端:

              header(‘Content-Type: application/json‘);

              //echo "[ {"bname":"","price":35.5},{} ]";

              $list = ...;

              echo json_encode($list);

       客户端:

              var obj = JSON.parse( xhr.responseText )

PHP响应头

原文:http://www.cnblogs.com/liangfc/p/7819720.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!