Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8904351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:06:29+00:00 2026-06-15T02:06:29+00:00

I make an xhr request, I get the response and I append some values

  • 0

I make an xhr request, I get the response and I append some values that I get to a table by appending. then I make second xhr request on another page, get some other results that I want to append under the previously inserted row..the problem is that every next append that I make instead of getting “under” the previously created row, gets before it..
I guess this is because these are dynamically created..but is there any way to solve this? without adding classes or ids to table or rows..

here is my code..
first the html

<body>
    <table border="1">
        <tr>
        <th>first cell</th>
        <th>second cell</th>
        </tr>
    </table>
    <div id="div1">
</body>

and my javascript

 function response(url, callback{
     //xhr request
  }

var url1 = "http://example1.com";
request(url1, function(response){
        var temp1 = document.getElementsByTagName("table")[0];
    var temp2create = document.createElement("tr");
    var temp3 = ("<td>" + someresponse + "</td><td>" + someotherresponse + "</td>");        
    temp2create.innerHTML = temp3;
    temp1.appendChild(temp2create);
 });
var url2 = "http://example1.com";
request(url2, function(response){
        var temp4 = document.getElementsByTagName("table")[0];
    var temp5create = document.createElement("tr");
    var temp6 = ("<td>" + someresponse + "</td><td>" + someotherresponse + "</td>");        
    temp5create.innerHTML = temp6;
    temp4.appendChild(temp5create);
 });

so, instead of having new row added after previous row, it gets before..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:06:30+00:00Added an answer on June 15, 2026 at 2:06 am

    It could be that the first xhr request is taking longer to complete than the second one. Therefore the second one appends its response before the first receives and appends its response. You could either make placeholder rows in the table if a fixed amount of requests will come back, such as:

    <body>
        <table border="1">
            <tr>
                <th>first cell</th>
                <th>second cell</th>
            </tr>
            <tr id="tr1">
    
            </tr>
            <tr id="tr2">
    
            </tr>
        </table>
    </body>
    

    and javascript:

    (url1,response())
    {
        document.getElementById("tr1").innerHTML("someresponse");
    }
    
    (url2,response())
    {
        document.getElementById("tr2").innerHTML("some other response");
    }
    

    Or you could link the requests to occur in sequence if time is not of the essence.

    request(url1, function(response){
        var temp1 = document.getElementsByTagName("table")[0];
        var temp2create = document.createElement("tr");
        var temp3 = ("<td>" + someresponse + "</td><td>" + someotherresponse + "</td>");        
        temp2create.innerHTML = temp3;
        temp1.appendChild(temp2create);
    
        var url2 = "http://example1.com";
        request(url2, function(response){
            var temp4 = document.getElementsByTagName("table")[0];
            var temp5create = document.createElement("tr");
            var temp6 = ("<td>" + someresponse + "</td><td>" + someotherresponse + "</td>");        
            temp5create.innerHTML = temp6;
            temp4.appendChild(temp5create);
         });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On mouseenter I make an AJAX request to get some dynamic text based on
I've been having some weird issues when it comes to make an AJAX request
When some action is invoked in my page, I make two ajax calls (A,
Couple questions about the implementation of the XHR request: I am trying to make
I'm attempting to make a cross domain script call to get some JSON data
Currently I am working on a ajax-based web application that does some XHR. I
I am making some consecutives(recrusive) ajax request to a php file that writes request
If I make a jquery AJAX request which is succesful I get back my
The documentation indicates that the error: option function will make available: XHR instance, a
In my Rails app i have an action that make ajax request. When i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.