zoukankan      html  css  js  c++  java
  • TP ajax

    ①Ajax使用:   注意传值的所有过程用的是小写,及时数据库列的名称中有大写字母

    控制器部分:

    AjaxController.class.php

    <?php 
    namespace HomeController;
    use ThinkController;
    class AjaxController extends Controller
        {
    
            public function Ajax(){
    
                if (empty($_POST)) {
                    $this->display();
                }
                else{
                    $code=$_POST["code"];
                    $nation=D('nation');
                    $attr=$nation->find($code);
                    $name=$attr["name"];
                    $this->ajaxReturn($name,'eval');
    
                }
            } 
    
    
        }

    ②Ajax.html 

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <script src="../../../../../jquery-1.11.2.min.js"></script>
    </head>
    <body>
    
    <input type="text" id="code"></input>
        <!-- <input type="button" value="显示" id="test"></input> -->    
    <span id="xianshi"></span>
    <form>
    <input type="text" required="required"></input>
    <input type="submit" value="提交"></input>
    </form>
    </body>
    </html>
    <script type="text/javascript">
        $(document).ready(function(e){
            
            $("#code").blur(function(){
                //alert($);
                var code=$('#code').val();
                $.ajax({
                    url:"__SELF__",
                    data:{code:code},
                    type:"POST",
                    dataType:"TEXT",
                    success:function(data){
                        //alert(data);
                        $("#xianshi").html(data);
                    }
                })
            })
        });
    </script>

  • 相关阅读:
    前端模块化
    PHP如何实现第三方分享
    python3运算符
    Python3基本数据类型
    Python3基本语法
    php 文件缓存
    php 链接转二维码图片
    php 根据文件内容来判断文件类型
    mysql中查询常用的关键字
    php天龙八部
  • 原文地址:https://www.cnblogs.com/zhanghaozhe8462/p/5523732.html
Copyright © 2011-2022 走看看