使用jquery发布到localhost django server

时间:2016-08-17 10:45:16

标签: jquery python ajax django google-chrome-extension

我有 chrome扩展,我希望它对我的localhost开发服务器(Django)进行ajax调用。

所以 js 看起来像:

$('#create_profile_form').submit(function(e){
        var pseudo = $("#create_pseudo_input").val()
        var email = $("#create_email_input").val()
        console.log(pseudo)
        $.post({
            url:'https://localhost:8000/test_ajax/',
            data:{
                'pseudo': pseudo,
                'email': email,
            },
            success:function(){
                alert("trop coule")
            }
        }).fail(function(){
            alert('ERROR')
        });
        return false;
    });

python 脚本:

def test_ajax(request):
    if request.is_ajax():
        message = "received {0} {1}".format(
            request.POST['email'], request.POST['pseudo'])
    else:
        message = "error -> no ajax"
    return HttpResponse(message)

服务器使用 django-sslserver

运行

当我提交表单时,我会在Chrome控制台中获得POST https://localhost:8000/test_ajax/ net::ERR_INSECURE_RESPONSE

我该怎么做:

1 /简化开发

2 /确保未来的生产安全

0 个答案:

没有答案