• ajax_post方式


    test_ajax_post.html

     1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
     2 <html>
     3     <head>
     4         <title>ajax_get方式</title>
     5         <meta http-equiv="content-type" content="text/html;charset=utf-8" />
     6         <meta name="keywords" content="html,css,js,ajax" />
     7         <style type="text/css">
     8             
     9         </style>
    10         <script type="text/javascript">
    11             function fun()
    12             {
    13                 var name="xioming";
    14                 var age="23";
    15                 var infor="name="+name+"&age="+age;
    16                 var xmlhttp;
    17                 if (window.XMLHttpRequest)
    18                 {// code for IE7+, Firefox, Chrome, Opera, Safari
    19                     xmlhttp=new XMLHttpRequest();
    20                 }
    21                 else
    22                 {// code for IE6, IE5
    23                     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    24                 }
    25                 xmlhttp.onreadystatechange=function()
    26                 {
    27                     if (xmlhttp.readyState==4 && xmlhttp.status==200)
    28                     {
    29                         document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    30                     }
    31                 }
    32                 xmlhttp.open("POST","test_ajax_post.php",true);
    33                 xmlhttp.setRequestHeader("content-type","application/x-www-form-urlencoded");
    34                 xmlhttp.send(infor);
    35             }
    36         </script>
    37     </head>
    38     <body>
    39         <h1>ajax_post提交方式</h1>
    40         <div><input type="button" value="点我" onclick="fun()" /></div>
    41         <div id="myDiv"></div>
    42     </body>
    43 </html>

    test_ajax_post.php

    1 <?php
    2     header("Content-type:text/html;charset=utf8");
    3     $name=$_POST["name"];
    4     $age=$_POST["age"];
    5     //echo $name." ".$age." hello world";
    6     print_r($_POST);
    7 ?>

    显示结果:

  • 相关阅读:
    windows补丁更新列表
    centos7网卡配置vlan
    exp备份工具使用说明
    windows系统SSL/TLS漏洞修复
    CDH平台:ZooKeeper 未授权访问【原理扫描】漏洞修复
    MySQL升级至5.7.35问题处理过程
    10fb does not support flow control autoneg问题处理
    vCenter异常日志:pg_tblspc找不到数据文件
    tcpdump命令
    排序算法总结
  • 原文地址:https://www.cnblogs.com/zizaifeihuaqingsimeng/p/6027400.html
Copyright © 2020-2023  润新知