1.创建一个网页:

<head>
    <meta charset="UTF-8">
    <title>Apollo</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css"
          integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"
            integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
            crossorigin="anonymous"></script>
    <script src="/static/jquery-3.1.1.js"></script>
    <script>

    </script>
    <style>
        .a_style {
            display: inline-block;
        }
    </style>
</head>
<div class="container">
    <div class="row">
        <h3>Ajax发送GET请求--JQuery</h3>
        <div>
            <a class="a_style btn btn-primary" onclick="AjaxGet1();">AjaxGet1</a>
            <a class="a_style btn btn-success" onclick="AjaxPost();">AjaxPost</a>
        </div>
    </div>
    <script src="/static/jquery-3.1.1.js"></script>
    <script>
        function AjaxGet1() {
            $.ajax({
                url: {% url 'main1' %},
                type: 'GET',
                data: {
                    'name':'apollo',
                    'age':28,
                    'gender':'male',
                },
                success: function (arg) {
                    console.log(arg);
                }
            })
        }


    </script>
</div>

 

2.创建二个URL线(一个用于提交数据,一个用于接收数据)

    re_path('main1/', views.main1, name='main1'),
    re_path('index1/', views.index1, name='index1'),

 

3.创建二个View视图(1个用于提交数据,一个用于接收参数)

def index1(request):
    return render(request, 'index1.html')


def main1(request):
    print(request.GET.get('name'))
    print(request.GET.get('age'))
    print(request.GET.get('gender'))
    print(request.GET)
    return HttpResponse("it's Ok")

4.打印结果

1 apollo
2 28
3 male
4 <QueryDict: {'name': ['apollo'], 'age': ['28'], 'gender': ['male']}>
5 [14/Nov/2018 13:06:55] "GET /main1/?name=apollo&age=28&gender=male HTTP/1.1" 200 7