zoukankan      html  css  js  c++  java
  • 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 )

  • 相关阅读:
    动手动脑
    原码反码补码
    考试感想
    第八周
    第七周
    第六周
    第五周
    第四周
    Hamburger Magi(hdu 3182)
    Doing Homework(hdu)1074
  • 原文地址:https://www.cnblogs.com/liangfc/p/7819720.html
Copyright © 2011-2022 走看看