[Answer]-Submit a form with jQuery function

1👍

You have to get and display the data from your ajax post function, where data is the response you render through your DJango server, for example:

t = Template("{{ link }}")
c = Context({"link": link})
t.render(c):

Your JS / jQuery should become something like this:

<script type="text/javascript">
    $(function() {
        $('#sendButton').click(function(e) {            
            e.preventDefault();
            var temp = $("#backupSubmit").serialize();
            validateForm();
            $.ajax({
                type: "POST",
                data: temp,
                url: 'backup/',

                success: function(data) {
                    // 'data' is the response from your server
                    // (=the link you want to generate from the server)

                    // Append the resulting link 'data' to your DIV '.response'
                    $(".response").html('<p>you can download it<a href="'+data+'">here</a></p>');

                    $(".response").show();
                }
            });
        });
    });
</script>

Hope this helps.

👤Littm

Leave a comment