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

130
Views
this.attr is not a function

button which triggers ajax call, and want to get async attributes

<button
   class="p-4 next-page-loader"
   async-url="myurl"
   async-data="{'username':'QuandaleDingle'}">
    Get Next Page
</button>

my index.js linked with html

function getNextPageFunction(){
    console.log('function started'); //works fine
    print(this.attr('async-url'));
    $.ajax({
        url: this.attr('async-url'),
        data: this.attr('async-data'),
        dataType: "json",
        error: function(rdata){
            console.log(rdata);
        },
        success: function(rdata){
            console.log(rdata);
        },
    })
};
$(document).ready(function(){
    console.log('start async'); //working fine
    console.log($(".next-page-loader").attr('class')); //working fine
    $(".next-page-loader").on("click", getNextPageFunction); //when-clicked-on-button-raises-error
    console.log("end async"); //working fine

})

the error in console

Uncaught TypeError: this.attr is not a function
    at HTMLButtonElement.getNextPageFunction (index.js:9:16)
    at HTMLButtonElement.dispatch (jquery-3.6.0.min.js:2:43064)
    at v.handle (jquery-3.6.0.min.js:2:41048)

i also tried passing this as an function input, not working either, raises same problem

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