码迷,mamicode.com
首页 > Web开发 > 详细

JS_XMLHttpRequest

时间:2020-01-13 23:50:39      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:function   idt   put   document   get   status   mini   ready   user   

 1 <head>
 2     <title>Powered By Leisureeen</title>
 3     <!-- <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/> -->
 4 </head>
 5 <script type="text/javascript">
 6     function b_req()
 7     {
 8         var t1=document.getElementById("txt1");
 9         var t2=document.getElementById("txt2");
10         var seVar=document.getElementById("seID");
11         Request(t1.value,seVar.selectedIndex?‘post‘:‘get‘,t2.value);
12     }
13     function Request(url, action, json)
14     {
15         var tout=document.getElementById("out");
16         var httpRequest=new XMLHttpRequest();
17         httpRequest.open(action, url, true);
18         httpRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");
19         httpRequest.send(json);
20         httpRequest.onreadystatechange = function ()
21         {
22             if(httpRequest.readyState == 4 && httpRequest.status == 200)
23             {
24                 var json = httpRequest.responseText;
25                 tout.value=json;
26             }
27         };
28     }
29 </script>
30 <body>
31     <div align="center">
32         <b><textarea id="txt1" style="height:40;width:500">http://www.jit.edu.cn</textarea><br>
33         <textarea id="txt2" style="height:100;width:500"></textarea><br>
34         <select id="seID"><option>Get</option><option>Post</option></select>
35         <input type="button" onclick="b_req()" value="Submit"><br>
36         <textarea id="out" style="height:280;width:500"></textarea><br>
37         Designer:Leisureeen</b><br>
38     </div>
39 </body>

JS_XMLHttpRequest

标签:function   idt   put   document   get   status   mini   ready   user   

原文地址:https://www.cnblogs.com/leisureeen/p/12189840.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!