<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Chapter 6 : Networking Considerations - Content Errors Happen</title>
<link rel="stylesheet" href="https://ajaxref.com/ch6/global.css" type="text/css" media="screen" />
<script src="https://ajaxref.com/ch6/ajaxtcr.js" type="text/javascript">
<script type="text/javascript">
function sendRequest()
{
var url = "https://ajaxref.com/ch6/helloworlderror.php";
var options = { method: "GET",
onSuccess : showResponse
};
AjaxTCR.comm.sendRequest(url, options);
}
function showResponse(response)
{
var responseOutput = document.getElementById("responseOutput");
responseOutput.innerHTML = "<h3>Status:</h3>" + response.xhr.status;
responseOutput.innerHTML += "<h3>responseText:</h3>" + response.xhr.responseText;
var xmlstr = response.xhr.responseXML;
var datevar = xmlstr.getElementsByTagName("message")[0].firstChild.nodeValue;
var ipvar = xmlstr.getElementsByTagName("message")[1].firstChild.nodeValue;
responseOutput.innerHTML += "<h3>Date:</h3>" + datevar;
responseOutput.innerHTML += "<h3>IP:</h3>" + ipvar;
}
window.onload = function ()
{
document.requestForm.requestButton.onclick = function () { sendRequest(); };
};
</head>
<body>
<div class="content">
<h1>Content Errors Happen</h1><br /><br />
<form action="#" name="requestForm" id="requestForm">
<input type="button" name="requestButton" id="requestButton" value="Send Request" /> <i>Request will result in 200 status but will be an error response.</i>
</form>
</div>
<br />
<div id="responseOutput" class="results"></div>
</body>
</html>