<html>
<head><title>HTTP POST</title></head>
<body>
<script language="javascript" type="text/javascript">
var request = false;
try {
request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = false;
}
}
}
if (!request)
alert("Error initializing XMLHttpRequest!");
</script>
<script language="javascript" type="text/javascript">
function callServer() {
var url = document.getElementById("url").value;
request.open("POST", url, true);
request.setRequestHeader("Content-Type", "text/xml");
request.setRequestHeader("Connection", "close");
request.onreadystatechange = updatePage;
request.send(document.getElementById("requestString").value);
// request.abort()
}
function updatePage(){
if (request.readyState == 4){
var head = request.getAllResponseHeaders();
var response = request.responseText;
document.getElementById("response").value = head + response;
}
}
function clearResponse(){
document.getElementById("response").value ="";
}
function clearRequest(){
document.getElementById("requestString").value ="";
}
</script>
Request URL: <input type="text" id="url" size="67" value="http://www.google.com">
<br>
<textarea name="requestString" id="requestString" rows="15" cols="120">
input request here
</textarea>
<p>
<input type="button" value="POST" onClick="callServer()" />
<input type="button" value="CLEAR" onClick="clearRequest()" />
<p>
<textarea name="response" id="response" rows="10" cols="120">
response will show here
</textarea>
<p>
<input type="button" value="CLEAR" onClick="clearResponse()" />
</body>
</html>
分享到:
相关推荐
c#实现的http post方法实例,测试通过。
1.一个简单的关于 HTTP GET,POST的简单实例 第一个方法是get 第二个是POST
主要介绍了使用mysql_udf与curl库完成http_post通信模块示例,需要的朋友可以参考下
压缩包内有httppost请求的主体代码以及请求相关的jar包。利用该工具类可以很方便的进行httppost请求
主要介绍了PHP中$GLOBALS['HTTP_RAW_POST_DATA']和$_POST的区别,结合具体实例形式分析了$GLOBALS['HTTP_RAW_POST_DATA']和$_POST的功能与使用过程中的区别,需要的朋友可以参考下
python 3.x 实现http post,有助于区别python2 python3
$_POST 与 php教程://input可以取到值,$HTTP_RAW_POST_DATA 为空 $_POST 以关联数组方式组织提交的数据,并对此进行编码处理,如urldecode,甚至编码转换 php://input 也可以实现此这个功能可以获得POST的原始数据...
【最新】C++ http post get 代码实例
一个http post协议传参 获取并传递值
利用$_POST超级全局变量接收表单的数据,然后利用echo输出到页面。 下面是代码: <!doctype html> <html> <head> <title>利用超级全局变量$_POST接收表单</title> <meta ...
用MFC实现的简单的HTTP的POST和GET方法,方便调用
基于VS2010利用C#实现HTTP在 GET和POST方法的样例代码,提供大家学习参考。欢迎下载学习
android HttpPost请求连接服务器端的实例 实现了异步加载,判断手机是否连接网络,请求超时处理
本文实例讲述了Python实现基于HTTP文件传输的方法。分享给大家供大家参考。具体实现方法如下: 一、问题: 因为需要最近看了一下通过POST请求传输文件的内容 并且自己写了Server和Client实现了一个简单的机遇HTTP的...
webservice调用实例,通过HttpPost调用
1.网页打不开的post不了,不存在的属性post不了,属性不区分大小写 2.post模式下内容格式要对,=赋值不能少 3.get模式下url=不能少 4.header 200表示响应成功,post 的内容要用web services readpostdata,两个VI...
最近在工作中,由于合作商只提供uRL,我这边需要通过HTTP请求Get或Post方式请求Json数据,然后解析JSON格式,解析json我使用的第三方库rapidjson。开发环境是64位win7,VS2015。
C#(cs文件) http连接api连接基础连接实例GET POST PUT DELETE
MFC使用H偷偷跑Client的GET和POST方法 MFC使用H偷偷跑Client的GET和POST方法
HttpRequest.HttpPost("http://www.baidu.com/","",ret); ofstream OutFile("C:\\11111111111111.txt"); //利用构造函数创建txt文本,并且打开该文本 OutFile << ret.c_str(); //把字符串内容,写入Test.txt...