Im trying to load a simple content from another server into a div.
File to load - banner_outage_sample.html
AJAX
(function($)
{
$(document).ready(function()
{
$.ajaxSetup(
{
cache: false,
beforeSend: function() {
$('#content-loaded').hide();
$('#loading').show();
},
complete: function() {
$('#loading').hide();
$('#content-loaded').show();
},
success: function() {
$('#loading').hide();
$('#content-loaded').show();
}
});
var $container = $("#content-loaded");
$container.load("http://www.svrsstatus.com/banner_outage_sample.html");
});
})(jQuery);
HTML
<div id="content-loaded"></div>
<div id="loading">Loading</div>
Basically when the content (banner_outage_sample.html) loads the 'loading' div hides and shows the 'content-loaded' div. It seems that the 'beforehand' function is working, but it will not load the content externally. Is it because of the security on the other server or what am I missing?
Here is the example on JSFIDDLE thats not working.
I also checked the Chrome debugger network and showed a security issue:
Access to XMLHttpRequest at 'svrsstatus.com/banner_outage_sample.html?_=1558710510006' from origin 'staging.svrs.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Looks like using AJAX is not the answer because of the security issue, but is there another best method to load content from another server besides using AJAX?
Thank you for your wisdom!