N
nameless
Hi at all. With this code ( below ), I insert in the tag with
"results" as identifier, the data that I retrieve from ajax function
( json structure "data" in below" ). But when "data.books.name" is
a string with apostrophes, the function onclick doesn't work !! How
can I resolve this issue ?
Thanks
e = document.getElementById('results');
for(i=0; i<data.books.length; i++) {
e.innerHTML += "<li><a href=\"#\" onclick=\"document.getElementById
(\'search-q\').value='" + data.books.name + "';\" >" + data.books
.name + "</a></li> ";
}
"results" as identifier, the data that I retrieve from ajax function
( json structure "data" in below" ). But when "data.books.name" is
a string with apostrophes, the function onclick doesn't work !! How
can I resolve this issue ?
Thanks
e = document.getElementById('results');
for(i=0; i<data.books.length; i++) {
e.innerHTML += "<li><a href=\"#\" onclick=\"document.getElementById
(\'search-q\').value='" + data.books.name + "';\" >" + data.books
.name + "</a></li> ";
}