Basically I have some HTML and Javascript designed to get data from a webpage. Using jsfiddle I know that the script with the id myscript does successfully get the link so that it becomes.
<script id="myscript" source="whats in the link">
So that part works but then that is supposed to then be used to load a file and get the data from it which isn't working for some reason. If I have a normal script tag with the src already set (without the document.getElementById thing in my code) then it successfully loads and displays the wanted data. But somehow even though the script src is changing to what i want it to be the data isn't being loaded.
<script>
var yqlcallback = function(data) {
var results = data.query.results;
document.write(results.span);
var rating = results.span;
rating = rating.slice(0, -1);
document.write(rating);
};
</script>
<script id="myscript"></script>
<script>
var link = "https://query.yahooapis.com/v1/public/yql?q=select%20content%20from%20html%20where%20url%3D%22http%3A%2F%2Fwww.team-des-fra.fr%2FCoM%2Fbf3.php%3Fp%3Dbj9912%22%20and%20xpath%3D'%2F%2F*%5B%40id%3D%22content%22%5D%2Fdiv%5B3%5D%2Fdiv%2Fspan'&format=json&callback=yqlcallback";
document.getElementById('myscript').setAttribute('src', link);
</script>