日期:2014-05-17 浏览次数:20583 次
<!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> </head> <body> <form action="upload_deal.php" method="post" name="form1" enctype="multipart/form-data" onsubmit="return upload();" > <select name="hour" id="hour" > <option value="0" selected="selected">请选择</option> <option value="1">哈哈</option> </select> <input name="image" type="file" id="image" /> <input name="submit" type="submit" value="上传" /> </form> <div id="status">f</div> <script> function GetXmlHttpObject() { var XMLHttp=null; try { XMLHttp=new XMLHttpRequest(); } catch(e) { try { XMLHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { XMLHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return XMLHttp; } function upload() { var flag=false; var XMLHttp=GetXmlHttpObject(); var url="upload_deal.php"; var dataStr="hour="+document.getElementById("hour").value; XMLHttp.open("POST",url,false); XMLHttp.setRequestHeader("content-type","application/x-www-form-urlencoded"); XMLHttp.send(dataStr); var resTest=XMLHttp.responseText; resTest=resTest.trim(); var response_compent="true"; if(resTest!=response_compent) { document.getElementById("status").innerHTML=resTest; } else flag=true; return flag; } </script> </body> </html>
if($_REQUEST['hour']==1) { echo "true"; } else { echo "false"; }
XMLHttp.onreadystatechange=function() { if(XMLHttp.readyState==4&&XMLHttp.status==200) { var resTest=XMLHttp.responseText; resTest=resTest.trim(); var response_compent="true"; if(resTest!=response_compent) { document.getElementById("status").innerHTML=resTest; } else flag=true; } }