zoukankan      html  css  js  c++  java
  • ThinkPHP+AJAX

    TestController.class.php

    <?php
    namespace HomeController;
    use ThinkController;
    class TestController extends Controller{
        
            public function test()
        {
            
                if(empty($_POST))
            {
                $this->display();
            }
                else
            {
                $code = I('code');
            
                $sheng = M('sheng');
                
                $name = $sheng->where("sheng_id = '{$code}'")->find();
                
                $this->ajaxReturn($name);
                
                
            }
        }
    }
    
    ?>
    View Code

    test.html

    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="__PUBLIC__/JQ/jquery-1.12.4.min.js"></script>
    </head>
    <body>
    <div>代号:<input type="text" id="code"></div>
    <input type="button" value="显示" id="btn">
    <div id="aa"></div>
    
    </body>
    </html>
    <script type="text/javascript">
    
    $(document).ready(function(e) {
        
        $("#btn").click(function(e) {
            
        var code = $("#code").val();
        
        $.ajax({
            
                  url:"__SELF__",
                  data:{code:code},
                  dataType:"json",
                  type:"POST",
                  success: function(data){
                
                     $("#aa").html(data.sheng_name);
                      
                      }
                })
    
            });
    });
    
    </script>
    View Code
  • 相关阅读:
    集训日记
    各种考试
    树上差分
    树的直径
    讲课
    adb常用命令
    关于appium的简单理解
    使用appium过程中常遇到的坑以及解决方案
    JMeter面试题
    fiddler面试题
  • 原文地址:https://www.cnblogs.com/sihuiming/p/5537446.html
Copyright © 2011-2022 走看看