分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 教程案例

AJAX 简单例程示例

发布时间:2023-09-06 01:54责任编辑:傅花花关键词:暂无标签
  • index.html

    <html><head> ???<script>function showHint(str){ ???if (str.length==0) ???{ ???????return; ???} ???if (window.XMLHttpRequest) ???{ ???????xmlhttp=new XMLHttpRequest(); ??// 申请一个 ?XMLHttpRequest 的 对象 ???} ???else ???{ ???????xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); ???} ???xmlhttp.onreadystatechange=function() ???{ ???????if (xmlhttp.readyState==4 && xmlhttp.status==200) ???????{ ???????????//document.getElementById("txtHint").innerHTML=xmlhttp.responseText; ???????????console.log(xmlhttp.responseText); ???????} ???} ???xmlhttp.open("GET","gethint.php?q="+str,true); ???// 打开,并传递一个数据过去,通过 GET 的方式 ???xmlhttp.send(); ???????// 发送}</script><button onclick="showHint('date')"> test it </button></head><body></body></html>
  • gethint.php

     ?1 <?php ?2 ?3 $q=$_GET["q"]; ??// 这里获取到上面的数据 ?4 ?5 echo $q; ?6 ?>

AJAX 简单例程示例

原文地址:https://www.cnblogs.com/chenfulin5/p/9052710.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved