ajax xmlhttp
<scriptlanguage="javascript">varhttp_request=false;functionsend_request(url){http_req...
<script language="javascript">
var http_request = false;
function send_request(url) {
http_request = false;
if(window.XMLHttpRequest) {
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
}
else if (window.ActiveXObject) {
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
window.alert("不能创建XMLHttpRequest对象实例.");
return false;
}
http_request.onreadystatechange = processRequest;
http_request.open("GET", url, false);
http_request.send(null);
}
function processRequest() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
document.getElementById("result").innerHTML = http_request.statusText;
} else {
alert("您所请求的页面有异常。");
}
}
}
function dosearch() {
var f = document.form1;
var xinwen = f.xinwen.value;
if(xinwen=="") {
window.alert("请输入查询");
f.xinwen.focus();
return false;
}
else {
document.getElementById("result").innerHTML="正在查询,请稍候";
send_request('http://www.baidu.com/s?wd='+escape(xinwen));
}
}
}
</script>
<p></p><p></p>
<form id="form1" name="form1" method="post" action="">
<span style="font-size:18px; color:#FF0000">我的搜索引擎</span>
<input id="Text1" type="text" />
请输入:
<input name="xinwen" type="text" id="geci" value="中国" size="60" maxlength="50" onKeyDown="submitForm()" />
<input type="button" name="search" value="查询" onClick="dosearch()"><br />
<span id="result">
</span>
</form>
</body>
</html>
怎么不行啊。。。span 显示OK 怎么会事 指点 展开
var http_request = false;
function send_request(url) {
http_request = false;
if(window.XMLHttpRequest) {
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
}
else if (window.ActiveXObject) {
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
window.alert("不能创建XMLHttpRequest对象实例.");
return false;
}
http_request.onreadystatechange = processRequest;
http_request.open("GET", url, false);
http_request.send(null);
}
function processRequest() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
document.getElementById("result").innerHTML = http_request.statusText;
} else {
alert("您所请求的页面有异常。");
}
}
}
function dosearch() {
var f = document.form1;
var xinwen = f.xinwen.value;
if(xinwen=="") {
window.alert("请输入查询");
f.xinwen.focus();
return false;
}
else {
document.getElementById("result").innerHTML="正在查询,请稍候";
send_request('http://www.baidu.com/s?wd='+escape(xinwen));
}
}
}
</script>
<p></p><p></p>
<form id="form1" name="form1" method="post" action="">
<span style="font-size:18px; color:#FF0000">我的搜索引擎</span>
<input id="Text1" type="text" />
请输入:
<input name="xinwen" type="text" id="geci" value="中国" size="60" maxlength="50" onKeyDown="submitForm()" />
<input type="button" name="search" value="查询" onClick="dosearch()"><br />
<span id="result">
</span>
</form>
</body>
</html>
怎么不行啊。。。span 显示OK 怎么会事 指点 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询