Reputation: 133
I have made Django Form with Html code how to make ajax call.I am new to Ajax. the problem is when we put input the output will come but form is invisible.if ajax will call this then everything will be fine
forms.py
from django import forms
class ReportForm(forms.Form):
text = forms.CharField(widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}))
html
{% extends 'base.html' %}
{% block content %}
<h1>StopWordsRemoval</h1>
<div>
<form action = "" method = "post" >
{% csrf_token %}
{{ form.as_p}}
<button type="submit">stopwordsremoval</button>
</div>
<div >
<ul>
<li>{{ naturallanguageprocessing }}</li>
<a href="{% url 'stopwordsremoval' %}" </a>
<style>
div {
width: 1000px;
border: 5px solid green;
padding: 10px;
margin: 10px;
}
</style>
</div>
</div>
{% endblock %}
Upvotes: 1
Views: 23
Reputation: 1059
This should get you started:
<script type='text/javascript'>
$(document).ready(function(){
$(form).on('submit', function(event){
$.ajax({
url: // where do you want the form sent?
type: 'POST',
data: this.serialize(),
});
});
});
</script>
Upvotes: 1