I just started learning JQuery and I am a little lost with this.
I want to retrieve an object from an external file but everything I am getting is the visual representation of the object.
I am reading the documentation and found getScript: https://api.jquery.com/jQuery.getScript/
My external file:
let mainSliderData = {
img1: '../vendors/img/slide1/slider.gif',
img2: '../vendors/img/slide1/slider.gif',
img3: '../vendors/img/slide1/slider.gif',
img4: '../vendors/img/slide1/slider.gif',
img5: '../vendors/img/slide1/slider.gif',
img6: '../vendors/img/slide1/slider.gif',
img7: '../vendors/img/slide1/slider.gif',
}
script.js file:
$(document).ready(function(){
$.getScript( "../../data/mainSliderData.js", function( data ) {
console.log(typeof data );
console.log( data );
}) .fail(function( jqxhr, settings, exception ) {
console.log('error:')
console.log(exception)
})
})
I want to get the object, but Instead when I log the answer into the console I get this:
How can I get the actual object coming from my external file?
