Flask 交互

<a href="{{url_for('test')}}">我是测试</a>

<button onclick="window.location.href='{{ url_for("test") }}'">点我啊</button>

<button onclick="{{ url_for("test") }}">点我啊</button>#这是错误的哦

<script>
    function testclick(name)
    {
        //window.location.href="{{ url_for("test") }}";
        window.open("{{ url_for("test") }}","_self");
    }
</script>
<button onclick="testclick('屋')">点击我啊</button>

------------------------------------------------------------------------

$.ajax({
                url:'/test',
                type:'POST',
                data:JSON.stringify({'username':'js','psw':'123456789'}),                #或者data: {jsdata: JSON.stringify({'username': 'js','psw': '132456789'})},
                #或者data:{'username':'js','psw':'123456789'},                #或者data:"username=js&psw=123",
                dataType: 'json',
                success:function(res){
                    console.log(res)
                    console.log(0)

                },
                error:function (res) {
                    console.log(res);
                    console.log(1)
                }
            })

  

posted @ 2021-09-25 12:02  CrossPython  阅读(49)  评论(0编辑  收藏  举报