• 注册
当前位置:1313e > ajax >正文

又一个ajax实例,结合jQuery

又一个ajax实例,配合jQuery

 
html
  1. DOCTYPE html>
  2. <html lang="zh-cn">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="renderer" content="webkit">
  6. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  7. <meta http-equiv="Cache-Control" content="no-siteapp"/>
  8. <title>moyu demotitle>
  9. <meta name="keywords" content="demo 测试 魔芋">
  10. <meta name="description" content="魔芋的测试示例">
  11. <meta name="robots" content="index,follow">
  12. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  13. <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js">script>
  14. <style>
  15. style>
  16. head>
  17. <body>
  18. <button>moyubutton>
  19. <p>p>
  20. <script>
  21. $("button").click(function(){
  22. $.post('http://localhost/moyu.php',{
  23. name:"nihao",
  24. city:"monkey"
  25. },function(data, status){
  26. $("p").html("Data: "+ data +"
    "
    +"Status: "+ status);
  27. })
  28. });
  29. script>
  30. body>
  31. html>
 
php
  1. php
  2. $name = isset($_POST['name'])? htmlspecialchars($_POST['name']):'';
  3. $city = isset($_POST['city'])? htmlspecialchars($_POST['city']):'';
  4. echo 'Dear '. $name;
  5. echo " ";
  6. echo 'Hope you live well in '. $city;
  7. ?>
 
魔芋:测试结果:
 
 
34.gif

 



 

转载于:https://www.cnblogs.com/moyuling/p/5272503.html

本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 162202241@qq.com 举报,一经查实,本站将立刻删除。

最新评论

欢迎您发表评论:

请登录之后再进行评论

登录
相关推荐