21,890
社区成员
发帖
与我相关
我的任务
分享
var url = 'insert.php?author='+author+ '&imgurl=' +imgurl+ '&content='+content.replace("#", "%23");
if ( content == '#' ) content = '%23';
var url = 'insert.php?author='+author+ '&imgurl=' +imgurl+ '&content='+content;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>无标题文档</title>
<script type="text/javascript">
var get = {
byId: function(id) {
return typeof id === "string" ? document.getElementById(id) : id
}
};
var xmlhttp;
function createXHR()
{
try
{
xmlhttp=new ActiveXObject("Msxm12.XMLHTTP"); //支持不同浏览器版本,下同
}
catch(e)
{
try
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
try
{
xmlhttp=new XMLHttpRequest();
if(xmlhttp.overrideMimeType)
{
xmlhttp.overrideMimeType("text/xml");
}
}
catch(e){}
}
}
if(!xmlhttp)
{
return false;
}
}
//发送请求
function doAjax(url)
{
//alert("Here we are!"+url);
createXHR();
xmlhttp.onreadystatechange=requestAjax;
alert("Here we are!"+url);
xmlhttp.open( "GET", url , true );
alert("Here we are!"+url);
xmlhttp.send( null );
//加延迟
//window.setTimeout(function(){xmlhttp.send( null );},1);
//alert("Here we are!");
}
//取得请求
function requestAjax()
{
if(xmlhttp.readyState==4)
{
if(xmlhttp.status==200)
{
//显示发布成功
document.getElementById('statue').innerHTML = xmlhttp.responseText;
}
}
}
function send(){
var oConBox = get.byId("conBox");
var content = oConBox.value;
var url = 'test1.php?url='+content;
alert(url);
doAjax(url);
}
</script>
</head>
<body>
<input id="conBox" name= "conBox" />
<input id="sendBtn" type="button" onclick="send()" />
<div id="statue"> </div>
</body>
</html>
<?php
header('Content-Type:text/html;charset=UTF-8');//避免输出中文乱码,linux下不需要
$url = $_GET['url'];
echo $url;
?>
//alert(content);
var url = 'insert.php?author='+author+ '&imgurl=' +imgurl+ '&content='+content;
//alert(url);
doAjax(url);