问题是我无法检索.json file
我在安全服务器上访问的结果,但这仅在使用任何版本的IE网络浏览器时才会发生。
Firefox 和 Chrome 运行良好,检索数据时不会报告控制台错误。
由于这只是一个 IE 问题,我想知道检索它的最佳方法,.json file
以便我可以解析接收到的数据的内容。想法?
这是代码:
<!doctype html>
<html>
<head>
<title>AFD TEST</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js"></script>
<script>
$(document).ready(function(){
$.getJSON('https://www.inquicker.com/facility/americas-family-doctors.json',
function(data){
var earliest = {};
var doctor = {};
var links = {};
$.each(data.schedules, function(i, name) {
var location = name.name.split(' - ')[0];
var dr_name = name.name.split(' - ')[1];
if (name.available_times.length) {
if (location in earliest) { // location has already been stored.
var newTime = parseAvailableDate(name.available_times[0].when);
if (newTime.isBefore(earliest[location])) {
earliest[location] = newTime;
doctor[location] = dr_name;
links[location] = name.available_times[0].url;
}
}
else {
earliest[location] = parseAvailableDate(name.available_times[0].when);
doctor[location] = dr_name;
links[location] = name.available_times[0].url;
}
}
});
displayDetailsBrentwood("Brentwood", earliest, doctor, links);
displayDetailsSmyrna("Smyrna", earliest, doctor, links);
displayDetailsSpring("Spring Hill", earliest, doctor, links);
});
});
function parseAvailableDate(dateString) {
var trimmedString = dateString.replace(/^\s\s*/, '');
var avTime=trimmedString.split(' ')[0],
ampm=trimmedString.split(' ')[1],
avDay=trimmedString.split(' ')[2];
var avDate = Date.parse("next "+avDay);
avDate.addHours(avTime.split(':')[0]).addMinutes(avTime.split(':')[1]);
if (ampm == "pm" && avTime.split(':')[0] != "12") avDate.addHours(12);
return avDate;
}
function displayDetailsBrentwood(location, earliest, doctor, links) {
$("#brentwood").append("<ul><a href='"+links[location]+"'>"+earliest[location].toString("MM/dd/yyyy h:mm tt")+"</a></ul>");
}
function displayDetailsSmyrna(location, earliest, doctor, links) {
$("#smyrna").append("<ul><a href='"+links[location]+"'>"+earliest[location].toString("MM/dd/yyyy h:mm tt")+"</a></ul>");
}
function displayDetailsSpring(location, earliest, doctor, links) {
$("#spring_hill").append("<ul><a href='"+links[location]+"'>"+earliest[location].toString("MM/dd/yyyy h:mm tt")+"</a></ul>");
}
</script>
</head>
<body>
<ul id="brentwood"></ul>
<ul id="smyrna"></ul>
<ul id="spring_hill"></ul>
</body>
</html>