JS_XMLHttpRequest
Posted Leisureeen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JS_XMLHttpRequest相关的知识,希望对你有一定的参考价值。
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的主要内容,如果未能解决你的问题,请参考以下文章