• PHP响应头


    (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 )

  • 相关阅读:
    5+ App开发Native.js入门指南
    uni-app vue-cli命令行
    本地uni-app原生插件提交云端打包
    编写package.json文件
    生成插件包
    无障碍角色 accessibilityRole (iOS, Android)
    ajax 整理
    Javascript分享笔记
    echarts 横坐标分行展示,以及文字显示顶部
    js总结(11)js作用域
  • 原文地址:https://www.cnblogs.com/liangfc/p/7819720.html
Copyright © 2020-2023  润新知