温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

php+js+html+ajax获取页面数据

发布时间:2020-04-04 15:00:58 来源:网络 阅读:602 作者:BlindCourage 栏目:web开发

login.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>

   <link type="text/css" href="app.css" rel="stylesheet">

   <meta name="viewport" content="width=device-width; initial-scale=1.4;  minimum-scale=1.0; maximum-scale=2.0"/>

   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

   <title></title>

   <script type="text/javascript" language="JavaScript">

       function login(){

           var account=document.getElementById('account');

           var password=document.getElementById('password');



           if(account.value==""){


               alert("请输入帐号");

               account.focus;

               return;

           }


           if(password.value==""){

               alert("请输入密码");

               password.focus;

               return;

           }


           var xmlHttp;


           //创建XMLHttpRequest对象

           if(window.ActiveXObject){

               xmlHttp = new ActiveXObject("Microsoft.XmlHttp");

           } else if(window.XMLHttpRequest){

               xmlHttp = new XMLHttpRequest();

           }


           xmlHttp.onreadystatechange = function(){

               if(xmlHttp.readyState==4){



                   if(xmlHttp.status==200){

                       //发送到服务器之后返回的消息

                       document.getElementById('msg').innerHTML=xmlHttp.responseText;

                   }

               }

           }

           var url="test.php";

           var queryString="account=" + account.value;

           xmlHttp.open("post",url,true);

           xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");

           xmlHttp.send(queryString);



       }

   </script>

</head>


<body >

<div class="appList"  >


   <table border="0" cellpadding="1" cellspacing="1" bordercolor="#AA7E7B">

       <tr>

           <td>

               帐号:

           </td>

           <td>

               <input id="account" type="text" maxlength="100" /><br/>

           </td>

       </tr>

       <tr>

           <td>

               密码

           </td>

           <td>

               <input id="password" type="password" maxlength="100" />

           </td>

       </tr>


   </table>

   <input   type="button" value="登录" onclick="login()"/>


   <div id="msg"></div>

</div>

</body>

</html>



test.php


<?php


   if(isset($_REQUEST['account'])){

       echo "get account:".$_REQUEST['account'];

   }

?>



向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI