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

326
Views
How to access $(this) in $.ajax({ }) block?

I want to access clicked button's methods inside ajax' block. I want to make my first game and I am new at javascript please help!

$(document).on("click",".play",function(e){
            e.preventDefault();
            $(this).text("Confirming..");//clicked button I want to access in ajax scope
            stopint();

            //get players' Ids
            var linkText = $(this).attr("href");
            var link = new URL("http://"+linkText);
            var p1 = link.searchParams.get("player1");
            var p2 = link.searchParams.get("player2");
            console.log(p1+","+p2);

            $.ajax({
                url: "matching_player.php",
                type: "POST",
                data: {player1 : p1, player2 : p2},
                success: function(data){
                    $(this).text("Connecting..");//clicked button's text()  
                }
            });
        });
over 4 years ago · Santiago Trujillo
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!