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

123
Views
How to store the response from post method globally inside the modal window?

I have a modal where list of title are displayed at left panel and its subcomponents are displayed at right side. This is the code, which will fetch all data in single array.

Array

[
    0 => [
        "title" => 'Title A',
        ....
        "subComponents" => [
        ]
    ],
    1 => [
        "title" => 'Title B',
        ....
        "subComponents" => [
        ]
    ]
]

Modal

$.post(url, {identification: identification}, function (res) {
    let parsedResponse = JSON.parse(res);
    $(".items-body").html('');
    $(".level-wrapper-right-up").html('');

    if (parsedResponse.success) {
        let records = parsedResponse.data;

        for (let j = 0; j < records.length; j++) {
            itemBodyContent.push("<div class='items-body-content left-heading'><span>" + records[j].title + "</span></div>");
        }

        levelWrapperRightUp.push("<div class='title'>" + records[0].heading + records[0].title + "</div>");
    }
    $(".items-body").html(itemBodyContent.join(''));
    $(".level-wrapper-right-up").html(levelWrapperRightUp.join(''));
});

$("#componentModal").modal();

Now when I make selection on title, its sub-components must also change.

$(".items-body").on("click", "div.left-heading", function() {
    alert($(this).text());
});

Since all my required data are already inside records. Is it possible to fetch on div.left-heading click without calling the POST method ?

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!