yuengling25
08-25-2016, 03:03 PM
1) Script Title: Featured Content Slider
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/featuredcontentslider.htm
3) Describe problem: As the title indicates, I am using the contentsource: ["inline", ""] method. I have written a script that is intended to make an API call and parses each piece of the returned JSON data into its own “contentdiv” item and appends it to the “.sliderwrapper” in my html page:
(function() {
var url = "http://xxxxxx";
var apiKey = "XXXXXXXXX";
$.getJSON(url + apiKey).done(function(data) {
$.each( data.sports[0].leagues[0].events, function() {
var score = $("<div/>", {class: "contentdiv"}).html('<table>' + '<tr>' + '<td>' + this.competitions[0].competitors[1].team.name + '</td>' + '</tr>' + '<tr>' + '<td>' + this.competitions[0].competitors[0].team.name + '</td>' + '</tr>' + '</table>');
$(score).appendTo($(".sliderwrapper"))
});
});
Problem is, I can’t get that data to display in the featured content slider at all. If I look at the source code after page load, everything appears to be as it would need to be in order for things to work. That is, my script appears to be working as intended. Just to make sure I wasn’t missing something simple, I even ran a test using some truly in-line content (i.e., <div class=”contentdiv”><p>This is a test…</p></div>), which worked just fine.
My question: is this a problem of timing between my own script and the contentslider.js file, considering that both are referenced in the head of my html? Or am I not seeing something in my own script that is causing things to not work? Any insight would be greatly appreciated.
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/featuredcontentslider.htm
3) Describe problem: As the title indicates, I am using the contentsource: ["inline", ""] method. I have written a script that is intended to make an API call and parses each piece of the returned JSON data into its own “contentdiv” item and appends it to the “.sliderwrapper” in my html page:
(function() {
var url = "http://xxxxxx";
var apiKey = "XXXXXXXXX";
$.getJSON(url + apiKey).done(function(data) {
$.each( data.sports[0].leagues[0].events, function() {
var score = $("<div/>", {class: "contentdiv"}).html('<table>' + '<tr>' + '<td>' + this.competitions[0].competitors[1].team.name + '</td>' + '</tr>' + '<tr>' + '<td>' + this.competitions[0].competitors[0].team.name + '</td>' + '</tr>' + '</table>');
$(score).appendTo($(".sliderwrapper"))
});
});
Problem is, I can’t get that data to display in the featured content slider at all. If I look at the source code after page load, everything appears to be as it would need to be in order for things to work. That is, my script appears to be working as intended. Just to make sure I wasn’t missing something simple, I even ran a test using some truly in-line content (i.e., <div class=”contentdiv”><p>This is a test…</p></div>), which worked just fine.
My question: is this a problem of timing between my own script and the contentslider.js file, considering that both are referenced in the head of my html? Or am I not seeing something in my own script that is causing things to not work? Any insight would be greatly appreciated.