4
I’m trying to use a browsing without refresh on the page, but when I click on the link, give this error:
XMLHttpRequest cannot load file:///Caminho.../paginas/login.html. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
I used this login.html
only as a test.
filing cabinet navegacao.js
, what makes the magic happen:
$(document).ready(function(){
var content = $('#conteudo');
//pre carregando o gif
loading = new Image(); loading.src = 'imgs/loading.gif';
$("#c_i_up a").click(function(e) {
e.preventDefault();
content.html( '<img src="imgs/loading.gif" />' );
var href = $( this ).attr('href');
$.ajax({
url: href,
success: function( response ){
var data = $('#conteudo').html(response);
//apenas atrasando a troca, para testar o loading
window.setTimeout( function(){
content.fadeOut('slow', function(){
content.html( data ).fadeIn();
});
}, 100 );
}
});
});
});
filing cabinet index.html
abridged:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="js/navegacao.js"></script>
</head>
<body>
<div id="conteudo">
<div id="c_i_up">
<a href="paginas/login.html">Teste</a>
</div><!--c_i_up-->
</div><!--conteudo-->
</body>
</html>
Note: I used Chrome and Firefox browser to test.
I had forgotten this rs, is what I was doing just to test it. Obg!
– Leonardo