I need to run a Jenkins job from a frontend button using Django+Python. I have made a header with html which has dropdown button. From reading many posts I learned that I can trigger my Jenkins job using AJAX. Can someone please tell me how to do that with an example snippets of view.py, and how to redirect it to a new HTML page when firing the on click event.
home.html
<div class="row">
<div class="col-sm-2">
<br><br>
<div class="well bs-sidebar" id="sidebar" style="background-color:#fff">
<ul class="nav nav-pills nav-stacked">
<h4>Application B <span class="badge badge-secondary"></span></h4>
</ul>
</div>
</div>
<div class="col-sm-10">
<h3>ACTIONS ALLOWED</h3>
<br>
<div class="dropdown">
<button class="btn btn-success btn-md" type="button" onclick="" data-toggle="dropdown">
List of scripts available
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Healthcheck</a></li>
<li><a href="#">Regresseion Testing</a></li>
<li><a href="#">Functional Testin</a></li>
<li><a href="#">Unit Testing</a></li>
<li class="divider"></li>
</ul>
<button class="btn btn-warning btn-md">
Cick to see the results
</button><br>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$('.btn-success').tooltip({title: "Execute", animation: true});
$('.btn-warning').tooltip({title: "Results!@", animation: false});
});
</script>
urls.py
from django.conf.urls import url
from . import views
urlpatterns=[
url(r'^$', views.index, name='index'),
url(r'^hello', views.hello, name='hello'),
]