zoukankan      html  css  js  c++  java
  • django基础~jquery交互

    一 绑定事件

      整体结构 $(selector).click(function(){$.ajax({})})

       1 #selector 为选择器标签ID 记得名字要加#    2 $.ajax({method: http方法 url:"url_context",data:JSON.stringify
    {“data”:variables},success:function(arg){},error:function(arg){})
         1 success:function(arg){
             var obj = jQuery.parseJSON(arg); //返回的数据进行join解析
             alert(obj)
            window.location.reload(); //页面刷新
            }}
         2 error:function(arg){
            var obj = jQuery.parseJSON(arg);
           alert(obj)
        }
    二 使用案例
    <script src="/static/js/jquery.js"></script>
    <script src="/static/js/pintuer.js"></script>
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/bootstrap.min.js"></script>
    <script type="text/javascript">
    function test(){
    alert("11111111")
    }
    $("#delete_user").click(function() {
    var id = $(this).parents("tr").children("td:nth-child(1)").text();
    alert("测试")
    $.ajax({
    url: "/api/v1/",
    method: "delete",
    data: JSON.stringify({"username":id}),
    success: function (arg) {
    window.location.reload()
    alert("删除成功")
     
    },
    error: function (arg) {
    var obj = jQuery.parseJSON(arg);
    alert(obj)
    }
    })
    })
    </script>
     

  • 相关阅读:
    linux 常用快捷键
    命令行远程链接
    mybatis参数错误 Parameter '×××' not found. Available parameters are [0, 1, param1, param2]
    mybatis延迟加载
    mybatis跨XML引用
    eclipse修改项目名称
    wait, WIFEXITED, WEXITSTATUS
    进程通信中如何进行值得传递?
    fork新建进程
    Ubuntu安装genymotion模拟器步骤
  • 原文地址:https://www.cnblogs.com/danhuangpai/p/14578288.html
Copyright © 2011-2022 走看看