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

195
Views
Adding another variable into template literal variable

How do I use a variable to make the following code reusable? Can I embed a variable in a template literal variable?

I am getting an object from the endpoint and I want to access object.CategoryName

here is my current code

export default function getCategoryAll(url, appendId, dataTitle, dataBody) {
    return $.ajax({
        url: url,
        type: 'GET',
        data: {

        },
        success: function (data) {
            console.log(data);
            // work here
            data.map((data) => {
                $(`#${appendId}`).append(`
                <div class="items-list-container">
                    <div class="items-list-content">
                    <div class="h5 items-list-content-title">${data + "." + dataTitle}}</div>
                    <div class="items-list-content-body d-flex"></div>
                    <button class="items-list-update-button badge btn btn-outline-success">Update</button></div>
                </div>`)
                return data
            })
        },
        error: function (jqXHR, textStatus, errorThrown) {
            // Empty most of the time...
            $('#setting-category-list').append("<h4>Error!</h4>")
        }
    });
}

getCategoryAll("/getCategoryAll", "setting-category-list", "CategoryName")
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!