一个ajax实例
2024-09-08 08:11:42
一个ajax实例
html
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<!--360,以webkit内核进行渲染-->
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<!--以最新内核进行渲染。-->
<meta http-equiv="Cache-Control" content="no-siteapp"/>
<!--百度禁止转码-->
<title>moyu demo</title>
<meta name="keywords" content="demo 测试 魔芋">
<meta name="description" content="魔芋的测试示例">
<meta name="robots" content="index,follow">
<!--定义网页搜索引擎索引方式-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
<style>
</style>
</head>
<body>
<script>
function showUser(str){
if(str ==""){
document.getElementById("txtHint").innerHTML ="";
return;
}
if(window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp =newXMLHttpRequest();
}else{// code for IE6, IE5
xmlhttp =newActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange =function(){
if(xmlhttp.readyState ==4&& xmlhttp.status ==200){
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","http://localhost/moyu.php?q="+ str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
<select name="users" onchange="showUser(this.value)">
<option value="">Select a person:</option>
<option value="1">PeterGriffin</option>
<option value="2">LoisGriffin</option>
<option value="3">GlennQuagmire</option>
<option value="4">JosephSwanson</option>
</select>
</form>
<br>
<div id="txtHint"><b>Person info will be listed here.</b></div>
</body>
</html>
php
<?php
$q=$_GET["q"];
echo "$q";
?>
魔芋测试:
最新文章
- CMS系统存储路径
- cordova 添加闪屏效果
- js中自定义事件,使用了jQuery
- 使用UpdatePanel 页面脚本不起作用
- 使用django表单,使网页添加上传文件,并分析文件。
- Appium对京东App中WebView的处理
- CLR 读书笔记
- centos mysql 编译安装
- T-SQL函数及用法--转
- ABAP函数:VIEW_MAINTENANCE_CALL(维护表视图等)
- apache启动报错:Cannot load php5apache2_2.dll into server
- 树莓派.安装Firefox浏览器
- linux 下mysql多实例安装
- Redis深入学习笔记(五)Redis阻塞原因
- 异步核心接口IAsyncResult的实现
- mvn package
- 利用arduino制作瓦力万年历-1.0
- Python之路PythonNet,第三篇,网络3
- 移动端调起qq聊天
- java socket之多人聊天室Demo
热门文章
- Unix\Linux | 总结笔记 | man帮助
- 51nod 1119 机器人走方格 V2
- Tree Recovery POJ - 2255
- 自定义View(11)**在onDraw中使用矩阵Matrix
- [转]C# 邮箱验证激活
- 线程池机制使nginx性能提高9倍
- [转]Android项目快速开发框架探索(Mysql + OrmLite + Hessian + Sqlite)
- android开发学习——This support library should not use a different version
- java之java.sql.SQLException: ResultSet is from UPDATE. No Data.
- php debug/phpstorm调试