zoukankan      html  css  js  c++  java
  • jquery 回调函数

    1.python 接口
    
    def testjquery(req):
     print req.get_full_path()
     print req.GET['username'];
     print req.GET['content'];
     return HttpResponse( req.GET['username'] + req.GET['content'])
    def upload(request):
    
    http://192.168.137.3:9000/testjquery/?username=aa&content=bb
    
    node2:/django/mysite/news/templates#cat a32.html 
    <form id="form1" action="#">
     <p>评论:</p>
     <p>姓名:<input type="text" name="username" id="username"/></p>
     <p>内容:<textarea name="content" id="content" rows="2" cpls="20"></textarea></p>
     <p><input type="button" id="send" value="提交"/></p>
     </form>
     <div class='comment'>已有评论:</div>
     <div id="resText">
    </div>
    <script type="text/javascript" src="/static/Js/jquery-2.2.2.min.js"></script>
    <script type="text/javascript" src="/static/Js/Monitor/displayonearray.js"></script>
    node2:/django/mysite/news/templates#
    
    
    
    node2:/django/mysite/news/templates#cat /django/mysite/static/Js/Monitor/a32.js 
    $(function(){
      $("#send").click(function(){
       $.get("/testjquery/",{
               username : $("#username").val(),
               content:$("#content").val()
       }
       );
    })
    })
    
    
    django 收到的信息:
    [21/Jan/2018 18:36:59] "GET /testjquery/?username=223343&content=43434 HTTP/1.1" 200 11
    /testjquery/?username=223343&content=43434
    223343
    43434
    [21/Jan/2018 18:36:59] "GET /testjquery/?username=223343&content=43434 HTTP/1.1" 200 11
    
    
    
    如果服务器端接收到传递的data数据并成功返回,那么久可以通过回调函数将返回的数据显示页面上。
    
    $.get()方法的回调函数只有两个参数,代码如下:
    
    function (data,textStatus){
        // data:  返回的内容,可以是XML文档,JSON文件,HTML片段等
    	// textStatus: 请求状态:success,error,notmodified,timeout 4种
    }
    
    data 参数代表请求返回的内容,textStatus 参数代表请求状态,而且回调函数只有当数据成功返回(success)后才被调用。
    
    
    
    $(function(){
      $("#send").click(function(){
       $.get("/testjquery/",{
               username : $("#username").val(),
               content:$("#content").val()
       },function (data,textStatus){
           console.log(data);
           console.log(textStatus);
           $("#resText").html(data);
       });
    
    })
    })
    ~                                                                                                                                                                                              
    ~                                                                                                                                                                                              
    ~                                                                                                                                                                                              
    ~              
    
    111aa222bb
    a32.js:7:8
    Navigated to http://192.168.137.3:9000/displayjquery/
    1112223
    a32.js:7:8
    success
    
    
    2) 数据格式
    
    服务器返回的数据格式可以有多种,它们都可以完成同样的任务。

  • 相关阅读:
    networktool3
    networktool2
    networktool
    Intel Zepher 介绍
    使用IPMI发送事件1让BMC log 填满
    Knights Landing
    Intel历代处理器
    Intel Datacenter Group Public Roadmap
    django的url路由
    position用法
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349291.html
Copyright © 2011-2022 走看看