【发布时间】:2015-11-21 21:33:41
【问题描述】:
我在使用 Javascript 的代码中使用 AJAX 调用。
function loadFacility(callback)
{
//alert('In loadFacility');
var xmlhttp;
var keys=document.firstCallInformation.facilityselect.value;
var urls="http://localhost:8080/webfdms/showFirstCallInformation.do?vitalsId=366";
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status == 200)
{
//var some=xmlhttp.responseXML.documentElement;
var response = xmlhttp.responseText;
console.log(response)
callback(xmlhttp.responseText);
}
}
xmlhttp.open("GET",urls,true);
xmlhttp.send(null);
}
function loadFacilityCallback(response){
if(response != null){
//alert(response);
console.log(response);
var div = document.createElement("div");
div.innerHTML = response;
document.getElementById("facilityselect").innerHTML = div.querySelectorAll("select#facilityselect");;
}
编辑: 我已经更新了我的回调函数。但是在这里我收到了选择列表作为[对象节点列表]。现在如何在我的 HTML 中显示?
在回调函数中,我收到了 HTML 格式的响应,现在我想解析该 HTML 响应,以便进一步处理它。我正在使用普通的javascript来做到这一点。如何解析作为 HTML 接收的 ajax 响应?
【问题讨论】:
标签: javascript html ajax html-parsing