zoukankan      html  css  js  c++  java
  • Django ajax提交 登录

    一、url

    from django.contrib import admin
    from django.urls import path
    from appo1 import views

    urlpatterns = [
    path('admin/', admin.site.urls),
    path('ajax_submit/',views.ajax_submit),
    ]

    二、views

    # Ajax POST 提交数据
    def ajax_submit(request):
    print(request.POST) #客户端发来的数据
    return render(request,'ajax_submit.html')

    三、html+ajax

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    </head>
    <body>
    <p align="center">用户名:<input id="vname" name="userName" type="text" placeholder="用户名" AUTOCOMPLETE="off"></p>
    <p align="center">密 码:<input id="vpwd" name="password" type="password" placeholder="密码" AUTOCOMPLETE="off"></p>
    <p align="center"><input type="button" onclick="AjaxSubmit();" value="提交"></p>

    <script src="/static/jquery-1.12.4.min.js"></script>
    <script>
    function AjaxSubmit(){
    var name=$("#vname").val()
    var password=$("#vpwd").val()
    alert(name)
    $.ajax({
    url:'/ajax_submit/',
    type:'POST',
    data:{vname:name,vpwd:password},
    success: function (arg) {
    }

    });
    }
    </script>

    </body>
    </html>
  • 相关阅读:
    Python paramik
    JavaScript和DOM
    HTML和CSS
    salt基本使用之二(2)
    nginx+php与apache+php性能对比
    varnish状态引擎2
    varnish状态引擎1
    varnish简介
    使用memcached实现tomcat集群session共享
    php安装redis扩展连接redis服务器
  • 原文地址:https://www.cnblogs.com/xibuhaohao/p/10490763.html
Copyright © 2011-2022 走看看