Jquery / JS question
- Started
- Last post
- 3 Responses
- dee-dubs
Probably being dense but the heat is stopping me working this out and its starting to piss me off.
getting some text data from JSON via jquery, but i want to use a variable no when retrieving the data so i can loop it, ie get myText1,myText2, myText3 and so on. Like this, but this isn't working.
$.getJSON('json/textDoc.json', function(data) {
$('#helpMessages').after('<p class="MsgTxt">'+data.case1[0].myText+helpCount+'</p>');
});
helpCount++;
}PS
$('#helpMessages').after('<p class="MsgTxt">'+data.case1[0].myText1'</p>')
works, its just making the no at the end of myText I cant seem to crack
- dee-dubs0
please?? hour on and still banging my head and i know this should be easy(ish)
- ideaist0
dee-dubs,
My limited knowledge requires you to first define the variable:
$helpCount = 1;
and then add into the function:
$helpCount = $helpCount + 1;
It doesn't seem you're defining your initial variable anywhere...Wish I had a precise answer for you bud!
Godspeed!
- dee-dubs0
it was :
$('#helpMessages').after('<p class="MsgTxt">'++data.case1[0]['myText'+helpCount]+'</p>'