0

I am currently pulling down records(json data) down from an online database with the following ajax call. This json data is populating scroll-able table. The issue is that the ajax call can only pull down a finite amount of data, around 30 entries before the scroll bar on the table stops.

Question: How can I change the call to load more of my json data once I scroll to the bottom of my table? I want to be able to display all the data on my website not just the first 30 entries in the database.

function populateTable(){       //populates the project list with active projects

var reqBody1 = { "filters":{ "and": [] }}
var $orgName = $('#orgName');


$.ajax({        
    type: 'POST',
    url: "https://myWebsite.com/path/to/data",
    contentType: 'application/json',
    data: JSON.stringify(reqBody1),
    success: function(res){

        for (i=0; i <30 ; i++){

            $orgName.append('<tr><td>' + res.records[i].field_1364364 + '</td></tr>');
                }
            }
    });
}

The following html is for the table that accepts the json information from the ajax call. The table calls a scroll-able class to add a scroll bar at the side of the table.

<div id="projListWrapper" class = "scrollable"> 
    <table class= "table table-hover table-striped">
        <tbody id ="orgName"></tbody>
    </table>
</div> 

Please let me know if I can provide more details on the issue.

Brian Tompsett - 汤莱恩
  • 5,195
  • 62
  • 50
  • 120
GoldenEagle
  • 105
  • 2
  • 15
  • http://stackoverflow.com/questions/11688279/jquery-infinite-scroll-on-a-table and you should probably use `GET` type instead of `POST`. – azeós Aug 05 '16 at 21:58
  • Have you tried your code? You seem to be on the right track – Kevin Jantzer Aug 05 '16 at 22:06
  • Thank you Azeos I will look into that link, what is the difference between POST and GET? I just tried GET and none of my json data appears. And Kevin yes this code is functional in extracting JSON data and displaying it. – GoldenEagle Aug 05 '16 at 22:19
  • Basically you use GET to request a resource and POST to submit data. Probably at the server side you're expecting a POST request, that's why it doesn't work. http://stackoverflow.com/questions/3477333/what-is-the-difference-between-post-and-get – azeós Aug 06 '16 at 03:37
  • The above code is working, I am transferring data from one website to another using POST, since that's what works for the servers we have – GoldenEagle Aug 07 '16 at 04:16

0 Answers0