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

167
Views
Cant browse through Dictionary in Javascript

I am using Ajax to send data and as a success, it sends some data back.

            $.ajax({
                method: "POST",
                url: "{% url 'upload-prop-images' %}",
                processData: false,
                contentType: false,
                mimeType: "multipart/form-data",
                data: fileData,
                success: function (data) {

                    console.log(data);
                    console.log(data.newCard);
                    console.log(data.newCard.prop_name);

                    }
                }
            })

views.py :

def uploadPropImages(request):

    prop_obj = list(Property.objects.filter(user=request.user).values())
    new_card = {}
    for obj in prop_obj:
        if obj['prop_name'] == prop_name:
            new_card['prop_name'] = obj['prop_name']
            new_card['prop_address'] = obj['prop_address']
            new_card['prop_type'] = obj['prop_type']
            new_card['prop_images'] = '/media/' + obj['prop_images']

    return JsonResponse({'status': 'Done', 'newCard': new_card})

In the first code block where success: function(data) {}, console.log(data) prints the data I am sending, that is {'status': 'Done', 'newCard': new_card}, but when I print, console.log(data.status) or console.log(data.newCard), I get undefined value. I cant understand why it prints undefined because I used AJAX may times earlier and It seem to work. It is how we can browser through the value of a dictionary in JAVASCRIPT, which in PYTHON is print(data['status']). Is the error anything related to the keys defined inside the AJAX function: processData, mimeType, contentType?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you need to call this

$.parseJSON();

Like this

               success: function (response) {
                var data= $.parseJSON(response);
                console.log(data);
                console.log(data.newCard);
                console.log(data.newCard.prop_name);

                }
about 4 years ago · Juan Pablo Isaza 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!