0

I have this code and i would like to get the first ten rows from the file on page load. Then i need to load 10 more by clickinng on the button.

$.ajax({
    url: 'drzave-brojevi.json',
    type: 'GET',
    dataType: 'json',
    success: function (json) {
        var inHTML = '<table id="predmeti" class="display"><thead><tr><th>Broj</th><th>Države</th><th>Odabir</th></tr></thead><tbody>';
        $.each(json, function (i, k) {

            inHTML += '<tr><td>' + k + "</td><td>" + i + '</td><td><input type="checkbox" name="drzava_odabir" value="' + i + '"></td></tr>';

        });
        inHTML += '</tbody></table>';
        $('#cilj')[0].innerHTML = inHTML;
    }
});
  • 1
    what have you tried so far? can you provide the rest of the code, connected to this snippet? as it looks to be out of the rest of the context. – Farside Apr 15 '18 at 10:40
  • 1
    All you have defined is a goal....but not any specific code related problem associated with attaining that goal. Take some time to read [ask] – charlietfl Apr 15 '18 at 10:48
  • { "Afganistan":"+93", "Albanija":"+355", "Alžir":"+213", "Andora":"+376", "Angola":"+244", "Antigva i Barbuda":"+1 (268)", "Argentina":"+54", "Armenija":"+374", "Australija":"+61", "Austrija":"+43", "Azerbajdžan":"+994", "Bahami":"+1 (24)", "Bahrein":"+973", "Bangladeš":"+880" } –  Apr 15 '18 at 10:48
  • You can add for loop and give it limit by 10. – Owais Aslam Apr 15 '18 at 10:50
  • [check this link](https://stackoverflow.com/questions/733314/jquery-loop-over-json-result-from-ajax-success?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa) – Owais Aslam Apr 15 '18 at 10:51
  • The code i provided works fine for me but i got the whole JSON file. I need just get the first 10 rows and show it as {country : call number : checkbox}. –  Apr 15 '18 at 11:02

0 Answers0