-4

i got every thing else to work. just having a problem with the .txt file. it just displays the doc path. does not display the actual document.

function callMeta() {

    var songName = $(nowPlaying).attr('data-songTitle');
    $('#songTitle').html(songName);
    var artistName = $(nowPlaying).attr('data-songArtist');
    $('#songArtist').html(artistName);
    var aBio = $(nowPlaying).attr('data-artistBio');
    $('.artistBio').html(aBio);
    var aCover = $(nowPlaying).attr('data-albumCover');
    $('img.albumCover').attr('src', aCover);
}

error, your browser doesn't support the HTML audio tag!

  • 1
    Where are you loading the .txt file? Some more relevant code? – Shaunak D Jul 21 '14 at 04:10
  • Tell us about the problem and we might be able to help you. – Felix Kling Jul 21 '14 at 04:10
  • error, your browser doesn't support the HTML audio tag! – Josh Smith Jul 21 '14 at 04:11
  • nowPlaying is an array of audio tags – Josh Smith Jul 21 '14 at 04:12
  • If you want to add more information, please **[edit]** your question. – Felix Kling Jul 21 '14 at 04:12
  • when its displayed its just the text of the file path not the actual doc – Josh Smith Jul 21 '14 at 04:13
  • You need jQuery **[`.load()`](http://api.jquery.com/load/)** here. And NOT `.html()` – Shaunak D Jul 21 '14 at 04:15
  • okay, i tried that. it didnt work. basiclly its a audio player. it plays a sond and displays an album cover, artist name, and song name, as well as a bio. when the song ends the next one is loaded and it need to display the new data. i used data-"artistBio.txt" and data-"albumCover.jpg". i cant get the txt document to load and replace the test that was there before. i got the album cover to load and change just not the txt file – Josh Smith Jul 21 '14 at 04:32

1 Answers1

0

Use .load() to load the contents of a file. .html() modifies the inner html of the element with the argument passed.

var aBio = $(nowPlaying).attr('data-artistBio');
$('.artistBio').load(aBio);

You can also use ajax to load file contents.

Community
  • 1
  • 1
Shaunak D
  • 20,588
  • 10
  • 46
  • 79
  • so, i want to replace the html with a txt file... so, i load it then replace it? i did something simular with the image file that is right below it. – Josh Smith Jul 21 '14 at 04:21
  • Image file just needs `src`, text file contents need `.load()`. To use `.html()` you need to use `ajax` to get the contents first. – Shaunak D Jul 21 '14 at 04:29
  • okay, i figured it out. var aBio = $(nowPlaying).attr('data-artistBio'); $('.artistBio').load(aBio); $('.artistBio').html(aBio); – Josh Smith Jul 21 '14 at 04:34