AJAX table population with bootstrap buttons











up vote
0
down vote

favorite












Have a base HTML I am appending NFL Teams and their scores to



 <table id="tablePreview" class="table table-hover table-sm">
<thead>
<tr>
<th>#</th>
<th>Home Team</th>
<th>Home Score</th>
<th>Away Score</th>
<th>Point Spread</th>
<th>Button</th>
</tr>
</thead>
<tbody>


I have simple Ajax call routine that will add 10 teams to the table.



function displaynflteams(){
var queryURL = "https://api.fantasydata.net/v3/nfl/scores/JSON/GameStatsByWeek/2018/8?key=ad398993c55d46449bde67a4095fef1b"
$.ajax({
url: queryURL,
method: 'GET'
})
.done(function(response) {
var results = response.data;
if (results == ""){
alert("Seriously? There is nothing here");
}

$(document).ready(function () {
var tr;
for (var i = 0; i < response.length; i++) {
tr = $('<tr/>');
tr.append("<td scope=row>" + i + "</td>");
tr.append("<td>" + results[i].HomeTeam + "</td>");
tr.append("<td>" + results[i].HomeScore + "</td>");
tr.append("<td>" + results[i].AwayScore + "</td>");
tr.append("<td id=odds-1>" + results[i].PointSpread + "</td>");
tr.append("<td id=place-bets-1><button class=btn btn-primary my-2 my-sm-0 id=pick-team-[" + i + "]>Select</button></td>";
$('table').append(tr);
}
});
}

displaynflteams();


For some reason the records are not showing up. I think it maybe the way I'm parsing my bootstrap attributes for the buttons










share|improve this question




























    up vote
    0
    down vote

    favorite












    Have a base HTML I am appending NFL Teams and their scores to



     <table id="tablePreview" class="table table-hover table-sm">
    <thead>
    <tr>
    <th>#</th>
    <th>Home Team</th>
    <th>Home Score</th>
    <th>Away Score</th>
    <th>Point Spread</th>
    <th>Button</th>
    </tr>
    </thead>
    <tbody>


    I have simple Ajax call routine that will add 10 teams to the table.



    function displaynflteams(){
    var queryURL = "https://api.fantasydata.net/v3/nfl/scores/JSON/GameStatsByWeek/2018/8?key=ad398993c55d46449bde67a4095fef1b"
    $.ajax({
    url: queryURL,
    method: 'GET'
    })
    .done(function(response) {
    var results = response.data;
    if (results == ""){
    alert("Seriously? There is nothing here");
    }

    $(document).ready(function () {
    var tr;
    for (var i = 0; i < response.length; i++) {
    tr = $('<tr/>');
    tr.append("<td scope=row>" + i + "</td>");
    tr.append("<td>" + results[i].HomeTeam + "</td>");
    tr.append("<td>" + results[i].HomeScore + "</td>");
    tr.append("<td>" + results[i].AwayScore + "</td>");
    tr.append("<td id=odds-1>" + results[i].PointSpread + "</td>");
    tr.append("<td id=place-bets-1><button class=btn btn-primary my-2 my-sm-0 id=pick-team-[" + i + "]>Select</button></td>";
    $('table').append(tr);
    }
    });
    }

    displaynflteams();


    For some reason the records are not showing up. I think it maybe the way I'm parsing my bootstrap attributes for the buttons










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Have a base HTML I am appending NFL Teams and their scores to



       <table id="tablePreview" class="table table-hover table-sm">
      <thead>
      <tr>
      <th>#</th>
      <th>Home Team</th>
      <th>Home Score</th>
      <th>Away Score</th>
      <th>Point Spread</th>
      <th>Button</th>
      </tr>
      </thead>
      <tbody>


      I have simple Ajax call routine that will add 10 teams to the table.



      function displaynflteams(){
      var queryURL = "https://api.fantasydata.net/v3/nfl/scores/JSON/GameStatsByWeek/2018/8?key=ad398993c55d46449bde67a4095fef1b"
      $.ajax({
      url: queryURL,
      method: 'GET'
      })
      .done(function(response) {
      var results = response.data;
      if (results == ""){
      alert("Seriously? There is nothing here");
      }

      $(document).ready(function () {
      var tr;
      for (var i = 0; i < response.length; i++) {
      tr = $('<tr/>');
      tr.append("<td scope=row>" + i + "</td>");
      tr.append("<td>" + results[i].HomeTeam + "</td>");
      tr.append("<td>" + results[i].HomeScore + "</td>");
      tr.append("<td>" + results[i].AwayScore + "</td>");
      tr.append("<td id=odds-1>" + results[i].PointSpread + "</td>");
      tr.append("<td id=place-bets-1><button class=btn btn-primary my-2 my-sm-0 id=pick-team-[" + i + "]>Select</button></td>";
      $('table').append(tr);
      }
      });
      }

      displaynflteams();


      For some reason the records are not showing up. I think it maybe the way I'm parsing my bootstrap attributes for the buttons










      share|improve this question















      Have a base HTML I am appending NFL Teams and their scores to



       <table id="tablePreview" class="table table-hover table-sm">
      <thead>
      <tr>
      <th>#</th>
      <th>Home Team</th>
      <th>Home Score</th>
      <th>Away Score</th>
      <th>Point Spread</th>
      <th>Button</th>
      </tr>
      </thead>
      <tbody>


      I have simple Ajax call routine that will add 10 teams to the table.



      function displaynflteams(){
      var queryURL = "https://api.fantasydata.net/v3/nfl/scores/JSON/GameStatsByWeek/2018/8?key=ad398993c55d46449bde67a4095fef1b"
      $.ajax({
      url: queryURL,
      method: 'GET'
      })
      .done(function(response) {
      var results = response.data;
      if (results == ""){
      alert("Seriously? There is nothing here");
      }

      $(document).ready(function () {
      var tr;
      for (var i = 0; i < response.length; i++) {
      tr = $('<tr/>');
      tr.append("<td scope=row>" + i + "</td>");
      tr.append("<td>" + results[i].HomeTeam + "</td>");
      tr.append("<td>" + results[i].HomeScore + "</td>");
      tr.append("<td>" + results[i].AwayScore + "</td>");
      tr.append("<td id=odds-1>" + results[i].PointSpread + "</td>");
      tr.append("<td id=place-bets-1><button class=btn btn-primary my-2 my-sm-0 id=pick-team-[" + i + "]>Select</button></td>";
      $('table').append(tr);
      }
      });
      }

      displaynflteams();


      For some reason the records are not showing up. I think it maybe the way I'm parsing my bootstrap attributes for the buttons







      javascript jquery ajax bootstrap-4






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 at 3:16

























      asked Nov 11 at 2:12









      NanoNet

      336




      336
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          The url you are making a GET request to is TootsieRollURL. That it not a url, unless was it just changed for this post. Where are you trying to fetch the data from?



          Also, if you did change out the url to hide it, can you verify the response data from browser devtools?






          share|improve this answer





















          • that was deliberately done as the issue was with the record creation
            – NanoNet
            Nov 12 at 22:36










          • add URL for viewers to see the data
            – NanoNet
            Nov 13 at 3:16











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245261%2fajax-table-population-with-bootstrap-buttons%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          The url you are making a GET request to is TootsieRollURL. That it not a url, unless was it just changed for this post. Where are you trying to fetch the data from?



          Also, if you did change out the url to hide it, can you verify the response data from browser devtools?






          share|improve this answer





















          • that was deliberately done as the issue was with the record creation
            – NanoNet
            Nov 12 at 22:36










          • add URL for viewers to see the data
            – NanoNet
            Nov 13 at 3:16















          up vote
          1
          down vote



          accepted










          The url you are making a GET request to is TootsieRollURL. That it not a url, unless was it just changed for this post. Where are you trying to fetch the data from?



          Also, if you did change out the url to hide it, can you verify the response data from browser devtools?






          share|improve this answer





















          • that was deliberately done as the issue was with the record creation
            – NanoNet
            Nov 12 at 22:36










          • add URL for viewers to see the data
            – NanoNet
            Nov 13 at 3:16













          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          The url you are making a GET request to is TootsieRollURL. That it not a url, unless was it just changed for this post. Where are you trying to fetch the data from?



          Also, if you did change out the url to hide it, can you verify the response data from browser devtools?






          share|improve this answer












          The url you are making a GET request to is TootsieRollURL. That it not a url, unless was it just changed for this post. Where are you trying to fetch the data from?



          Also, if you did change out the url to hide it, can you verify the response data from browser devtools?







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 11 at 2:23









          Brandon Lyons

          613




          613












          • that was deliberately done as the issue was with the record creation
            – NanoNet
            Nov 12 at 22:36










          • add URL for viewers to see the data
            – NanoNet
            Nov 13 at 3:16


















          • that was deliberately done as the issue was with the record creation
            – NanoNet
            Nov 12 at 22:36










          • add URL for viewers to see the data
            – NanoNet
            Nov 13 at 3:16
















          that was deliberately done as the issue was with the record creation
          – NanoNet
          Nov 12 at 22:36




          that was deliberately done as the issue was with the record creation
          – NanoNet
          Nov 12 at 22:36












          add URL for viewers to see the data
          – NanoNet
          Nov 13 at 3:16




          add URL for viewers to see the data
          – NanoNet
          Nov 13 at 3:16


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245261%2fajax-table-population-with-bootstrap-buttons%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python