📄 postdata.js
字号:
var xmlHttp=createXmlHttpRequestObject();
function createXmlHttpRequestObject()
{
var xmlHttp;
try
{
xmlHttp=new XMLHttpRequest();
}
catch(e)
{
var XmlHttpVersions=new Array('MSXML2.XMLHTTP.6.0','MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP');
for(var i=0;i<XmlHttpVersions.length && !xmlHttp;i++)
{
try
{
xmlHttp=new ActiveXObject(XmlHttpVersions[i]);
}
catch(e){}
}
}
if(!xmlHttp)
alert("Error creating the XMLHttpRequest object.");
else
return xmlHttp;
}
function process()
{
if(xmlHttp)
{
try
{
username=encodeURIComponent(document.getElementById("author").value);
content=encodeURIComponent(document.getElementById("content").value);
xmlHttp.open("POST","postdata.php?author="+username+"&content="+content,true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.onreadystatechange=handleRequestStateChange;
xmlHttp.send(null);
}catch(e)
{
alert("Can't connect to server:\n"+e.toString());
}
}
}
function handleRequestStateChange()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
try
{
//document.write "Hello,world!";
handleServerResponse();
//document.write("Hello,World!");
}
catch(e)
{
alert("Error reading the response:" +e.toString());
}
}
else
{
alert("There was a problem retrieving the data:\n"+xmlHttp.statusText);
}
}
}
function handleServerResponse()
{
myUser=document.getElementById('list_user');
myContent=document.getElementById('list_content');
myUser.innerHTML=username;
myContent.innerHTML=content;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -