Here is my JavaScript code snippet:
patients.prototype.GetPatient = function(patient_id,callback)
{
var xmlhttp;
var fullpath;
try {
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var pat = parseJson(xmlhttp.response);
if (pat) {
callback(parseJson(xmlhttp.response));
}
else {
alert('Null object returned?');
}
}
else if (xmlhttp.status == 404) {
alert('Unable to find Retrieve Patient Service');
}
}
xmlhttp.open("GET", "RetrievePatient.ashx?PatientId=" + patient_id, true);
xmlhttp.send();
}
catch (e) {
alert('Unable to retrieve requested patient details');
}
}
function parseJson(jsonString) {
var res;
try {
alert('Parsing JSON');
res = JSON.parse(jsonString);
}
catch (e) {
alert('Call to evaluate result failed with error ' + e.message + ' Evaluating Json ' + jsonString );
};
return res;
}
When executed in IE10 or Chrome, the patient details are returned successfully. However, when running on a page in IE8, the JSON data comes back as null causing the process to fail.
Does anyone have suggestions on how I can modify this code to work properly in IE8?