Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda