一个ajax实例

 
html
 
  1. <!DOCTYPE html>
  2. <html lang="zh-cn">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="renderer" content="webkit">
  6. <!--360,以webkit内核进行渲染-->
  7. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  8. <!--以最新内核进行渲染。-->
  9. <meta http-equiv="Cache-Control" content="no-siteapp"/>
  10. <!--百度禁止转码-->
  11. <title>moyu demo</title>
  12. <meta name="keywords" content="demo 测试 魔芋">
  13. <meta name="description" content="魔芋的测试示例">
  14. <meta name="robots" content="index,follow">
  15. <!--定义网页搜索引擎索引方式-->
  16. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  17. <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
  18. <style>
  19. </style>
  20. </head>
  21. <body>
  22. <script>
  23. function showUser(str){
  24. if(str ==""){
  25. document.getElementById("txtHint").innerHTML ="";
  26. return;
  27. }
  28. if(window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  29. xmlhttp =newXMLHttpRequest();
  30. }else{// code for IE6, IE5
  31. xmlhttp =newActiveXObject("Microsoft.XMLHTTP");
  32. }
  33. xmlhttp.onreadystatechange =function(){
  34. if(xmlhttp.readyState ==4&& xmlhttp.status ==200){
  35. document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
  36. }
  37. }
  38. xmlhttp.open("GET","http://localhost/moyu.php?q="+ str,true);
  39. xmlhttp.send();
  40. }
  41. </script>
  42. </head>
  43. <body>
  44. <form>
  45. <select name="users" onchange="showUser(this.value)">
  46. <option value="">Select a person:</option>
  47. <option value="1">PeterGriffin</option>
  48. <option value="2">LoisGriffin</option>
  49. <option value="3">GlennQuagmire</option>
  50. <option value="4">JosephSwanson</option>
  51. </select>
  52. </form>
  53. <br>
  54. <div id="txtHint"><b>Person info will be listed here.</b></div>
  55. </body>
  56. </html>
 
 
php
 
 
  1. <?php
  2. $q=$_GET["q"];
  3. echo "$q";
  4. ?>
 
 
 
魔芋测试:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

最新文章

  1. CMS系统存储路径
  2. cordova 添加闪屏效果
  3. js中自定义事件,使用了jQuery
  4. 使用UpdatePanel 页面脚本不起作用
  5. 使用django表单,使网页添加上传文件,并分析文件。
  6. Appium对京东App中WebView的处理
  7. CLR 读书笔记
  8. centos mysql 编译安装
  9. T-SQL函数及用法--转
  10. ABAP函数:VIEW_MAINTENANCE_CALL(维护表视图等)
  11. apache启动报错:Cannot load php5apache2_2.dll into server
  12. 树莓派.安装Firefox浏览器
  13. linux 下mysql多实例安装
  14. Redis深入学习笔记(五)Redis阻塞原因
  15. 异步核心接口IAsyncResult的实现
  16. mvn package
  17. 利用arduino制作瓦力万年历-1.0
  18. Python之路PythonNet,第三篇,网络3
  19. 移动端调起qq聊天
  20. java socket之多人聊天室Demo

热门文章

  1. Unix\Linux | 总结笔记 | man帮助
  2. 51nod 1119 机器人走方格 V2
  3. Tree Recovery POJ - 2255
  4. 自定义View(11)**在onDraw中使用矩阵Matrix
  5. [转]C# 邮箱验证激活
  6. 线程池机制使nginx性能提高9倍
  7. [转]Android项目快速开发框架探索(Mysql + OrmLite + Hessian + Sqlite)
  8. android开发学习——This support library should not use a different version
  9. java之java.sql.SQLException: ResultSet is from UPDATE. No Data.
  10. php debug/phpstorm调试