// // variables and constants // //apiURL="http://localhost:8888" apiURL="https://sonar.jacquesingram.online" $(document).ready(function () { fetch(); setInterval(fetch, 1000*120); }); function fetch() { console.debug(" -> :: fetchLeaderboardDetails()"); $.ajax({ type: "GET", url: apiURL + "/jobs/", dataType: 'json', // <-- Set dataType to 'json' //contentType: "text/plain", crossDomain: false, success: function (data, status, jqXHR) { console.log("good"); profitleaderboard(data); }, error: function (error, status) { console.log("error fetching leaderboard", error); } }); } function load() { console.debug(" -> :: fetchLeaderboardDetails()"); $.ajax({ type: "GET", url: apiURL + "/jobs/load", dataType: 'json', // <-- Set dataType to 'json' //contentType: "text/plain", crossDomain: false, success: function (data, status, jqXHR) { console.log("good"); profitleaderboard(data); }, error: function (error, status) { console.log("error fetching leaderboard", error); } }); } function profitleaderboard(jobList) { console.log("jobList / " ,jobList); var html = ''; size = jobList.length; console.log("size / " + size); for (var i =0;i< jobList.length; i++) { html += ''; html += '' + (i+1) + ''; // Integer (ranking) html += '' + jobList[i].site + ''; // Integer (ranking) html += '' + jobList[i].company + ''; // String (username) html += ''+jobList[i].title+ ''; // html += '' + + ''; // String (username) html += '' + jobList[i].location + ''; // String (username) html += '' + jobList[i].job_type + ''; // String (username) html += '' + jobList[i].is_remote + ''; // String (username) html += '' + jobList[i].description + ''; // String (username) html += ''; } $('#leaderboard > tbody').html(html); }