I need to replace a part of an AJAX response,I have an ajax response on this form for example:
{"vals":["val1223","val1389","val1897","val1321"]}
I need to replace 'val1' for each of these values and render them in italic form for example.
I tried like this but nothing changed on my display:
var queryvar =$('#search').val();//value sent in AJAX query
display="";
display +="<ul>";
//in response
if(data.vals){
$.each(data.vals, function(k,v){
v = v.replace(queryvar, '<i>' +queryvar+ '</i>');
display +='<li>' + v + '</li>';
});
}
display +="</ul>";
$('#results').html(display);