Skip to content

Instantly share code, notes, and snippets.

@lcomino
Created August 29, 2015 23:26
Show Gist options
  • Save lcomino/2b52d539298bcfd34d5b to your computer and use it in GitHub Desktop.
Save lcomino/2b52d539298bcfd34d5b to your computer and use it in GitHub Desktop.
div-ajax-load
//jquery
$.ajax({
url : 'seu-arquivo.html',
success : function (data){
$('.ajax').html(data);
},
error : function(){
$('.ajax').html('Erro ao carregar conteúdo...');
}
});
//js puroo
var req = new XMLHttpRequest();
req.open('GET', 'seu-arquivo.html');
req.onload = function(){
var div = document.getElementById('ajax');
div.innerHTML = req.response;
};
req.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment