Below is the code which I implemented to get dropdown list items by Ajax in JSP:
if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
var data = xmlHttp.responseText.split("~");
alert(data);
var listb = document.getElementById("listbox");
var textValue;
var optionItem;
for ( var count = 0; count < data.length; count++) {
textValue = (data[count]);
optionItem = new Option(textValue, textValue, false, false);
listb.options[listb.length] = optionItem;
}
}
But I am getting some more text with first item:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
But I am not getting from where it is coming. Where does it come from and how can I solve it?