JS_XMLHttpRequest
<head> <title>Powered By Leisureeen</title> <!-- <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/> --> </head> <script type="text/javascript"> function b_req() { var t1=document.getElementById("txt1"); var t2=document.getElementById("txt2"); var seVar=document.getElementById("seID"); Request(t1.value,seVar.selectedIndex?'post':'get',t2.value); } function Request(url, action, json) { var tout=document.getElementById("out"); var httpRequest=new XMLHttpRequest(); httpRequest.open(action, url, true); httpRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded"); httpRequest.send(json); httpRequest.onreadystatechange = function () { if(httpRequest.readyState == 4 && httpRequest.status == 200) { var json = httpRequest.responseText; tout.value=json; } }; } </script> <body> <div align="center"> <b><textarea id="txt1" style="height:40;width:500">http://www.jit.edu.cn</textarea><br> <textarea id="txt2" style="height:100;width:500"></textarea><br> <select id="seID"><option>Get</option><option>Post</option></select> <input type="button" onclick="b_req()" value="Submit"><br> <textarea id="out" style="height:280;width:500"></textarea><br> Designer:Leisureeen</b><br> </div> </body>
posted on 2020-01-13 22:59 Leisureeen 阅读(140) 评论(0) 编辑 收藏 举报