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

148
Views
how to get button tag from ajax response on html in javascripts

Propose : get or select tag button with javascripts after ajax showing all data,

Issue : I can't get the button affter ajax respond.

Description : I use javascript and select button with id = "btn_infor" use querySelectorAll(), but when I was selecting, the data not found and my variabel Nodelists have nothing.

Javascript(Ajax) :

function get_databyvisibility(num,variabels){
        visible = num
        $.ajax({
            type:'GET',
            url:`/post-jsondata/${visible}/`,
            dataType:'json',
            success: function(response){
                variabels(response.data)
            },
            error: function(error){
                console.log(error)
            }
        })

Then I use this function to show data to html.

function call_datas(result){
        result.map(post =>{
            more_procudt.innerHTML += `
                <div class="product-box">
                    <img src="${post.image_urls}" alt="" class="product-img" id="more-imgpro">
                    <h2 class="product-title" id="more-titlepro">${post.name}</h2>
                    <span class="price" id="more-pricepro">$${post.price}</span>
                    <div class="detail-info">
                        <button class="but-info" id="btn_infor">Detail</button>
                    </div>
                </div>
            `
        })

I call the function : get_databyvisibility(4,call_datas)

after I call the function and then I use this code to select this tag " <button class="but-info" id="btn_infor">Detail</button>"

This the code to select all button : const button_information = document.querySelectorAll("btn_infor");

After I select all buttons my variable has nothing nodelist.

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!