• 0

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /var/www/html/cnasolution/site/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/site/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/site/index.php
Line: 315
Function: require_once

I'm trying to write an AJAX post function to be recieved by one of my django views, however it isn't working.

Here is my ajax call

                $.ajax({                      url : 'localhost:8000/increment?amount=5&persist=yes',                     type : 'POST',                     data : {                         'amount' : amount                     },                     dataType:'json',                     success : function(data) {                                   alert('Data: '+data);                     },                     error : function(request,error)                     {                      }                 }); 

and here is the django view that is supposed to be recieving it

@login_required def Increment(request):     if request.method=="GET":         amount = request.GET.get('amount', 0) # returns 5         persist = request.GET.get('persist', 'no') #returns yes     profile = get_object_or_404(Profile, user=request.user)     profile.coins += amount     profile.save(update_fields=['coins'])     return HttpResponse('') #return void 
Download script demo [LINK] [Origin]
Download script demo [LINK 2] [Onedrive] Download script demo [LINK 2] [Google drive]