日期:2014-05-17 浏览次数:20643 次
<script type="text/javascript">
/*通过异步传输XMLHTTP发送参数到ajaxServlet,返回符合条件的XML文档*/
var req=null;
function addMessage(){
var message=document.getElementById('message');
if(message.value==""){
alert("请输入留言内容");
}else{
getResult();
message.value="";
message.select();
}
}
function getResult() {
var message=document.getElementById('message');
var sendstr;
var url="http://192.126.119.139:8080/WebService/servlet/AjaxServlet?time="+new Date().toString();
if(message==null){
sendstr="";
}else{
sendstr = "sendmsg=" + message.value;
}
if(window.ActiveXObject)
{
req = new ActiveXObject('Microsoft.XMLHTTP');
}
else if(window.XMLHttpRequest)
{
req = new XMLHttpRequest();
}
if (req) {
req.onreadystatechange = complete;
req.open("POST", url);
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req.send(sendstr);
}
}
function complete() {
if (req.readyState == 4) {
var v;
if (req.status==200) {
v = req.responseText;
showmsg(v);
}
if(req.status==0){
v = "抱歉,留言功能咱不支持你所使用的浏览器== ===抱歉,留言功能咱不支持你所使用的浏览器== ===抱歉,留言功能咱不支持你所使用的浏览器== ";
showmsg(v);
}
}
}
function showmsg(v){
var values=v.split("===");
if(values.length>0){
for(var i=0;i<values.length;i++){
if(values[i]!=null){
var values2=values[i].split("==");