Answer the question
In order to leave comments, you need to log in
How to call a python function via js ajax in django?
Tell me how to spell correctly
. in js i'm a complete zero below can be heresy:
there is an html button:
<button onclick="click()" class="btn">Жмяк</button>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript">
function click() {
$.ajax({
url: 'stat/';
success: alert('Оно наконец заработало!');
});
};
</script>
from django.urls import path
from . import views
urlpatterns = [
path('stat/', views.stat),
]
def stat(request):
''''какой-то мой код''
Answer the question
In order to leave comments, you need to log in
function click() {
$.ajax({
url: 'stat/';
success: function() {
alert('Оно наконец заработало!')
}
})
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question