Missing the jquery library
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$.get('teste.php', function(data) {
document.getElementById('somediv').innerHTML = data;
});
</script>
<div id="somediv"></div>
With pure Javascript
function makeHttpObject() {
try {return new XMLHttpRequest();}
catch (error) {}
try {return new ActiveXObject("Msxml2.XMLHTTP");}
catch (error) {}
try {return new ActiveXObject("Microsoft.XMLHTTP");}
catch (error) {}
throw new Error("Não foi possível criar o objeto de solicitação HTTP.");
}
var request = makeHttpObject();
request.open("GET", "URL_da_pagina", true);
request.send(null);
request.onreadystatechange = function() {
if (request.readyState == 4)
document.getElementById('somediv').innerHTML = (request.responseText);
};
HTML
<div id="somediv"></div>
is missing library
– user60252