我有以下代码适用于除 IE 之外的所有浏览器:我被拒绝访问。请帮忙!!!我已经看了很多例子,但仍然无法解决这个问题。我想保持简单,因为我所做的只是从 URL 返回一些文本。
<script type="text/javascript">
// Insure the document is loaded...
$(document).ready(function() {
// Set the URL for the POS API...
var PosApiUrl = 'https://test.safety.com/posapi/getposmessage?app=RMIS';
// Load the POS API Message...
function loadPOSMessage(edurl) {
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else if (window.XDomainRequest) {
xmlhttp = new XDomainRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var jsonEdition = xmlhttp.responseText;
var objEdition = JSON.parse(jsonEdition);
$.each(objEdition, function(key, val) {
if (val.length === 0) {
$('.posMsgContainer').hide();
} else {
$('.posMsgContainer').html(val);
}
});
}
};
xmlhttp.open("GET", edurl, true);
xmlhttp.send();
}
// Make the call to load the POS message...
loadPOSMessage(PosApiUrl);
});
</script>