嘿,我想根据结果更改字体颜色或 responseText。例如,如果未找到 responseText,我想将字体颜色设置为红色。否则,它将是黑色的。它当前正在显示正确的 responseText;我只想在必要时更改颜色。这是我目前的 Ajax:
function newXMLHttpRequest()
{
var xmlreq = false;
if (window.XMLHttpRequest)
{
xmlreq = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
try
{
xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e2)
{
alert("Error: Unable to create an XMLHttpRequest.");
}
}
return xmlreq;
}
function getLocation(location)
{
var getLocation= newXMLHttpRequest(); // sending request
getLocation.open("GET", "/PP?PAGE=GETLOCATIONNAME&ROUTINGNUM=" + location, false);
getLocation.send(null); // getting location
document.getElementById("location_div").innerHTML = getLocation.responseText;
}
responseText 将在 HTML 的表格中:
<tr>
<td class="ajax_msg">
<div id="location_div"></div>
</td>
<td> </td>
</tr>
<tr>
<td>
<div class="column1">
<p class="label_top">
*Routing Number</p>
<p class="field_top"><input type="text" id="location" name="location" size="28" maxlength="9" onblur="getLocation(this.value);" /></p>
欢迎任何建议。提前致谢!