i got input , textarea, problem i'mm sending ajax text , words , counting how inputs have word in text, , sending list of objects of class have 2 vals:quantity , word,and want show result that:"word"-quantity" , these things need put in ul li,so tried created ul , li jquery still cant how put in html append vals of list. thats part of code:
function makeulli() { var sub_ul = $('<ul/>'); $.each(data, function (i) { var sub_li = $('<li/>'); $(sub_li).appendto(sub_ul); }); } $(".texnwords").append("<section class='searchresult'><h4>result:</h4><p>words: <p>text:<br>" + text + "</p></section>");
so need put created ul , li's in append values list.
not sure you're trying do, if you're trying access data variable can this:
function makeulli() { var sub_ul = $('<ul/>'); $.each(data, function (index, value) { // access value.yourvalue var sub_li = $('<li/>'); sub_ul.append(sub_li); }); $(".texnwords").append(sub_ul); }
update:
guess mean this?
function makeulli() { var sub_ul = $('<ul/>'); $.each(data, function (index, value) { var sub_li = $('<li/>').html(value.word+'-'+value.quantity); sub_ul.append(sub_li); }); $(".texnwords").append(sub_ul); }
if in doubt, how data structure variable is, try console.log() either "value" or "data".
Comments
Post a Comment