I want to fetch a String from my DB and put it into my paragraphs:
<p id="q_1"></p>
<p id="q_2"></p>
This here works fine:
$.get("bewertung/get/1", function (data) {
document.getElementById("q_1").innerHTML = data[0].question;
})
This here doesnt work. Why and how to solve this?
for( var j = 1; j <= 5; j++){
$.get("bewertung/get/"+j+"", function (data){
document.getElementById("q_"+j+"").innerHTML = data[0].question;
})
}
//data[0].question is the field in the DB