When i click on a href they go on Script code but form Script not call the views.py function!
Link code::
<a class="likebutton" href="#">
<span id="unlock">
<i class="fas fa-lock"></i> Send Message
</span>
</a>
Script code::
<script type="text/javascript">
$('.likebutton').click(function(){
$.ajax(
{
type:"GET",
url: "sendnotification",
success: function(){
alert('Done')
} }) });
</script>
urls.py::
url(r"^sendnotification",views.sendnotification,name='sendnotification'),
views.py::
@csrf_exempt
def sendnotification(request):
if request.method == 'GET':
push_service = FCMNotification(api_key="*********")
registration_id = "****************"
data_message = {
"Nick" : "Mario",
"body" : "great match!",
"Room" : "PortugalVSDenmark"}
result = push_service.single_device_data_message(registration_id=registration_id, data_message=data_message)
return HttpResponse('success')