Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

426
Views
Django get JSON object sent from Javascript to Django Views

I need to pass a Json Object value after making an API call to my views.py in order to render in django template. After making an ajax call I'm not able to get the value in django`

let application = JSON.parse(sessionStorage.getItem("appId"));
let kycStatus = application.applicationId

$.ajax({
    type: "GET",
    dataType: "json",
    url: `${url}/${kycStatus}`,
    headers: {
         'Content-Type': 'application/json',
         'X-API-Key': '',
        },
        data: {
            senddata: JSON.stringify(),
        },
        success: function(data)  {
            document.getElementById("kyc-status").innerHTML = data.overallResult.status
            console.log(data.overallResult.status)
        }
     

})`

in my views.py

def is_ajax(request):
    return request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'


def kycsubmit(request):
    """ A view to return the index page"""
    if is_ajax(request=request):
       if request.method == 'GET':
            data = request.GET.get('senddata')
            print(data)
           
    return render(request, 'kycsubmit/onboard.html')
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

the print method in def kycsubmit(request): it will only print to the terminal. Use context variable here

 def kycsubmit(request): """ A view to return the index page""" if is_ajax(request=request): if request.method == 'GET': data = request.GET.get('senddata') return render(request, 'kycsubmit/onboard.html',{'data':data})
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!