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

189
Views
Django AJAX "Uncaught TypeError: $(...).attrs is not a function"

When I tap the anchor tag to send the data, I get this error Uncaught TypeError: $(...).attrs is not a function.

I did console.log($(this)), the output is [object Object].

I also did console.log(JSON.stringify($(this))), the output is {"0":{},"length":1}

HTML, My anchor tag:

                <a href="{% url 'my-site' slug=object.anotherObject.slug %}" id="update-done"
                    data-donePk="{{object.pk}}" 
                >Done</a>

JS, My AJAX

    $(document).on('click', '#update-done', function(e) {
        e.preventDefault()
        let confirmation = confirm("Are you sure you want to make done?");
    
        if (confirmation) {
            console.log("this: " + JSON.stringify($(this)))
            alert($(this))

            // Error comes from this line below
            var objectPk = $(this).attrs('data-donePk')
    
            var makeDone = 'post'
            $.ajax({
                
                url: "/site/make_done/",
                data: {
                    'csrfmiddlewaretoken': "{{ csrf_token }}",
                    "objectPk":objectPk,
                    "makeDone": makeDone,
                },
    
                type: "POST",
                dataType: 'json',
    
                cache: false,
    
                success: function(data) {
                    console.log(data)
                },
            })
            
        }
        
    
        
    });
about 4 years ago · Santiago Gelvez
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!