hellofangfang

<!DOCTYPE HTML>
<html>
<head>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
<script type="text/javascript">
    $(function(){
        //按钮单击时执行
        $("#testAjax").click(function(){
              
              //Ajax调用处理
            $.ajax({
               type: "POST",//规定传输方式
               url: "new.php",//提交URL
               data: {\'name\':$(\'#name\').val(),\'age\':$(\'#age\').val()},//提交的数据
               success: function(data){
                        $("#myDiv").html(\'<h2>\'+data+\'</h2>\');//交互成功回调
                  }
            });
            
         });
    });
</script>    
</head>
    <body>
        <input type="text" name="name" id="name"><br/>
        <input type="text" name="age" id="age"><br/>
        <div id="myDiv"><h2>通过 AJAX 改变文本</h2></div>
        <button id="testAjax" type="button">Ajax改变内容</button>
    </body>
</html>

<?php
    $msg=\'Hello,\'.$_POST[\'name\'].\',your age is \'.$_POST[\'age\'].\'!\';
    echo $msg;

 

来源:https://blog.csdn.net/wu_ning/article/details/59630497

分类:

技术点:

相关文章:

  • 2022-01-21
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
  • 2021-11-23
  • 2021-09-23
  • 2022-01-06
猜你喜欢
  • 2022-12-23
  • 2022-02-26
  • 2021-12-04
  • 2021-08-09
  • 2022-01-08
  • 2021-12-16
  • 2022-12-23
相关资源
相似解决方案